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


Ignore:
Timestamp:
Nov 18, 2002, 10:53:35 PM (23 years ago)
Author:
darin
Message:
  • property and string improvements giving a 7% or so improvement in JavaScript iBench
  • kjs/property_map.h: Rewrite to use a hash table.
  • kjs/property_map.cpp: Ditto.
  • kjs/string_object.h:
  • kjs/string_object.cpp: (StringInstanceImp::StringInstanceImp): Construct a string with the right value instead of putting the string in later. (StringInstanceImp::get): Get the length from the string, not a separate property. (StringInstanceImp::put): Ignore attempts to set length, since we don't put it in the property map. (StringInstanceImp::hasProperty): Return true for length. (StringInstanceImp::deleteProperty): Return false for length. (StringObjectImp::construct): Call new StringInstanceImp constructor. Don't try to set a length property.
  • kjs/ustring.h: Make the rep deref know how to deallocate the rep.
  • kjs/ustring.cpp: (UString::release): Move the real work to the rep's deref, since the hash table now uses the rep directly.
  • kjs/object.h: Remove unused field.
File:
1 edited

Legend:

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

    r2740 r2749  
    592592void UString::release()
    593593{
    594   if (!rep->deref()) {
    595     delete [] rep->dat;
    596     delete rep;
    597   }
     594  rep->deref();
    598595}
    599596
     
    665662  return (l1 < l2) ? 1 : -1;
    666663}
    667 
    668 // Algorithm concept from Algorithms in C++, Sedgewick, Program 14.1.
    669 int KJS::hash(const UString &s, int hashTableSize)
    670 {
    671     int h = 0;
    672     int length = s.size();
    673     int prefix = length < 8 ? length : 8;
    674     for (int i = 0; i != prefix; i++)
    675         h = (127 * h + s[i].unicode()) % hashTableSize;
    676     int suffix = length < 16 ? 8 : length - 8;
    677     for (int i = suffix; i != length; i++)
    678         h = (127 * h + s[i].unicode()) % hashTableSize;
    679     return h;
    680 }
Note: See TracChangeset for help on using the changeset viewer.