[armedbear-cvs] r12490 - trunk/abcl/src/org/armedbear/lisp

Ville Voutilainen vvoutilainen at common-lisp.net
Sat Feb 20 20:36:41 UTC 2010


Author: vvoutilainen
Date: Sat Feb 20 15:36:40 2010
New Revision: 12490

Log:
More cleanups, introduce a function for adjusting return values
when a function is implemented in terms of another.


Modified:
   trunk/abcl/src/org/armedbear/lisp/StringFunctions.java

Modified: trunk/abcl/src/org/armedbear/lisp/StringFunctions.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/StringFunctions.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/StringFunctions.java	Sat Feb 20 15:36:40 2010
@@ -255,6 +255,17 @@
         }
     };
 
+    private static LispObject 
+        swapReturnValue(int original,
+                        StringIndicesAndChars indicesAndChars) {
+        if (original < 0) {
+            return NIL;
+        }
+        int delta = original - indicesAndChars.start1;
+        int retVal = indicesAndChars.start2 + delta;
+        return Fixnum.getInstance(retVal);
+    }
+
     // ### %string>
     // Case sensitive.
     private static final Primitive _STRING_GREATER_THAN = new pf__string_greater_than();
@@ -273,12 +284,7 @@
                                       fifth, sixth,
                                       third, fourth);
             int tmp = lessThan(indicesAndChars);
-            if (tmp < 0) {
-                return NIL;
-            }
-            int delta = tmp - indicesAndChars.start1;
-            int retVal = indicesAndChars.start2 + delta;
-            return Fixnum.getInstance(retVal);
+            return swapReturnValue(tmp, indicesAndChars);
         }
     };
 
@@ -346,12 +352,7 @@
                                       fifth, sixth,
                                       third, fourth);
             int tmp = lessThanOrEqual(indicesAndChars);
-            if (tmp < 0) {
-                return NIL;
-            }
-            int delta = tmp - indicesAndChars.start1;
-            int retVal = indicesAndChars.start2 + delta;
-            return Fixnum.getInstance(retVal);
+            return swapReturnValue(tmp, indicesAndChars);
         }
     };
 
@@ -420,12 +421,7 @@
                                       fifth, sixth,
                                       third, fourth);
             int tmp = stringLessp(indicesAndChars);
-            if (tmp < 0) {
-                return NIL;
-            }
-            int delta = tmp - indicesAndChars.start1;
-            int retVal = indicesAndChars.start2 + delta;
-            return Fixnum.getInstance(retVal);
+            return swapReturnValue(tmp, indicesAndChars);
         }
     };
 
@@ -495,12 +491,7 @@
                                       fifth, sixth,
                                       third, fourth);
             int tmp = stringNotLessp(indicesAndChars);
-            if (tmp < 0) {
-                return NIL;
-            }
-            int delta = tmp - indicesAndChars.start1;
-            int retVal = indicesAndChars.start2 + delta;
-            return Fixnum.getInstance(retVal);
+            return swapReturnValue(tmp, indicesAndChars);
         }
     };
 




More information about the armedbear-cvs mailing list