Changeset 2736 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp


Ignore:
Timestamp:
Nov 18, 2002, 1:55:23 PM (23 years ago)
Author:
darin
Message:
  • fix worst speed problems on the sort page of the iBench JavaScript test

Sped up JavaScript iBench by 70%, the sort page by 88%.

  • kjs/array_object.h: Add array-specific sort functions.
  • kjs/array_object.cpp: (compareByStringForQSort): Added. (ArrayInstanceImp::sort): Added. (compareWithCompareFunctionForQSort): Added. (ArrayProtoFuncImp::call): Use ArrayInstanceImp::sort if the object being sorted is actually an array.
  • kjs/object.h: Add argumentsPropertyName.
  • kjs/object.cpp: Add argumentsPropertyName.
  • kjs/function.cpp: (FunctionImp::FunctionImp): Use argumentsPropertyName to avoid making a UString. (FunctionImp::call): Ditto. (ActivationImp::ActivationImp): Ditto.
  • kjs/function_object.cpp: (FunctionObjectImp::construct): Ditto.
  • kjs/ustring.h: Added compare function for -1/0/+1 comparison.
  • kjs/ustring.cpp: (KJS::compare): Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r2304 r2736  
    643643  return (l1 < l2);
    644644}
     645
     646int KJS::compare(const UString& s1, const UString& s2)
     647{
     648  const int l1 = s1.size();
     649  const int l2 = s2.size();
     650  const int lmin = l1 < l2 ? l1 : l2;
     651  const UChar *c1 = s1.data();
     652  const UChar *c2 = s2.data();
     653  int l = 0;
     654  while (l < lmin && *c1 == *c2) {
     655    c1++;
     656    c2++;
     657    l++;
     658  }
     659  if (l < lmin)
     660    return (c1->unicode() > c2->unicode()) ? 1 : -1;
     661
     662  if (l1 == l2) {
     663    return 0;
     664  }
     665  return (l1 < l2) ? 1 : -1;
     666}
Note: See TracChangeset for help on using the changeset viewer.