Changeset 12490


Ignore:
Timestamp:
02/20/10 20:36:40 (13 years ago)
Author:
vvoutilainen
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/StringFunctions.java

    r12489 r12490  
    256256    };
    257257
     258    private static LispObject
     259        swapReturnValue(int original,
     260                        StringIndicesAndChars indicesAndChars) {
     261        if (original < 0) {
     262            return NIL;
     263        }
     264        int delta = original - indicesAndChars.start1;
     265        int retVal = indicesAndChars.start2 + delta;
     266        return Fixnum.getInstance(retVal);
     267    }
     268
    258269    // ### %string>
    259270    // Case sensitive.
     
    274285                                      third, fourth);
    275286            int tmp = lessThan(indicesAndChars);
    276             if (tmp < 0) {
    277                 return NIL;
    278             }
    279             int delta = tmp - indicesAndChars.start1;
    280             int retVal = indicesAndChars.start2 + delta;
    281             return Fixnum.getInstance(retVal);
     287            return swapReturnValue(tmp, indicesAndChars);
    282288        }
    283289    };
     
    347353                                      third, fourth);
    348354            int tmp = lessThanOrEqual(indicesAndChars);
    349             if (tmp < 0) {
    350                 return NIL;
    351             }
    352             int delta = tmp - indicesAndChars.start1;
    353             int retVal = indicesAndChars.start2 + delta;
    354             return Fixnum.getInstance(retVal);
     355            return swapReturnValue(tmp, indicesAndChars);
    355356        }
    356357    };
     
    421422                                      third, fourth);
    422423            int tmp = stringLessp(indicesAndChars);
    423             if (tmp < 0) {
    424                 return NIL;
    425             }
    426             int delta = tmp - indicesAndChars.start1;
    427             int retVal = indicesAndChars.start2 + delta;
    428             return Fixnum.getInstance(retVal);
     424            return swapReturnValue(tmp, indicesAndChars);
    429425        }
    430426    };
     
    496492                                      third, fourth);
    497493            int tmp = stringNotLessp(indicesAndChars);
    498             if (tmp < 0) {
    499                 return NIL;
    500             }
    501             int delta = tmp - indicesAndChars.start1;
    502             int retVal = indicesAndChars.start2 + delta;
    503             return Fixnum.getInstance(retVal);
     494            return swapReturnValue(tmp, indicesAndChars);
    504495        }
    505496    };
Note: See TracChangeset for help on using the changeset viewer.