Ignore:
Timestamp:
Nov 19, 2002, 5:23:02 PM (23 years ago)
Author:
darin
Message:
  • another step towards atomic identifiers; storing hash in the string rep. gives about a 1.5% speedup in the JavaScript iBench
  • kjs/ustring.h: Add a hash field to UString::Rep.
  • kjs/ustring.cpp: (UString::Rep::create): Set hash to uninitialized value. (UString::Rep::destroy): Do the deleting in her, and call Identifier if needed. (UString::Rep::computeHash): Added. (UString::append): Set hash to 0 when modifying the string in place. (UString::operator=): Ditto.
  • kjs/property_map.cpp: Use the hash from UString.
  • kjs/identifier.h: Added aboutToDestroyUStringRep.
  • kjs/identifier.cpp: (Identifier::aboutToDestroyUStringRep): Added.
File:
1 edited

Legend:

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

    r2766 r2769  
    6565}
    6666
    67 int PropertyMap::hash(const UString::Rep *s) const
    68 {
    69     int h = 0;
    70     int length = s->len;
    71     int prefixLength = length < 8 ? length : 8;
    72     for (int i = 0; i < prefixLength; i++)
    73         h = (127 * h + s->dat[i].unicode()) & _tableSizeHashMask;
    74     int suffixPosition = length < 16 ? 8 : length - 8;
    75     for (int i = suffixPosition; i < length; i++)
    76         h = (127 * h + s->dat[i].unicode()) & _tableSizeHashMask;
    77     return h;
     67inline int PropertyMap::hash(const UString::Rep *s) const
     68{
     69    return s->hash() & _tableSizeHashMask;
    7870}
    7971
Note: See TracChangeset for help on using the changeset viewer.