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


Ignore:
Timestamp:
Nov 19, 2002, 6:35:01 PM (23 years ago)
Author:
darin
Message:
  • a few more globals for often-used property names
  • conversion to Identifier from UString must now be explicit
  • kjs/error_object.cpp:
  • kjs/function.cpp:
  • kjs/function_object.cpp:
  • kjs/identifier.cpp:
  • kjs/identifier.h:
  • kjs/lexer.cpp:
  • kjs/nodes.cpp:
  • kjs/number_object.cpp:
  • kjs/object.cpp:
  • kjs/object.h:
  • kjs/string_object.cpp:
  • kjs/testkjs.cpp:
  • kjs/ustring.cpp:
  • kjs/ustring.h:
File:
1 edited

Legend:

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

    r2769 r2772  
    165165  r->rc = 1;
    166166  r->_hash = 0;
    167 
    168167  return r;
    169168}
     
    172171{
    173172  if (capacity == capacityForIdentifier)
    174     Identifier::aboutToDestroyUStringRep(this);
     173    Identifier::remove(this);
    175174  delete [] dat;
    176175  delete this;
    177176}
    178177
    179 void UString::Rep::computeHash() const
    180 {
    181     int length = len;
     178unsigned UString::Rep::computeHash(const UChar *s, int length)
     179{
    182180    int prefixLength = length < 8 ? length : 8;
    183181    int suffixPosition = length < 16 ? 8 : length - 8;
     
    185183    unsigned h = length;
    186184    for (int i = 0; i < prefixLength; i++)
    187         h = 127 * h + dat[i].unicode();
     185        h = 127 * h + s[i].unicode();
    188186    for (int i = suffixPosition; i < length; i++)
    189         h = 127 * h + dat[i].unicode();
     187        h = 127 * h + s[i].unicode();
    190188    if (h == 0)
    191189        h = 0x80000000;
    192     _hash = h;
     190    return h;
     191}
     192
     193unsigned UString::Rep::computeHash(const char *s)
     194{
     195    int length = strlen(s);
     196    int prefixLength = length < 8 ? length : 8;
     197    int suffixPosition = length < 16 ? 8 : length - 8;
     198
     199    unsigned h = length;
     200    for (int i = 0; i < prefixLength; i++)
     201        h = 127 * h + (unsigned char)s[i];
     202    for (int i = suffixPosition; i < length; i++)
     203        h = 127 * h + (unsigned char)s[i];
     204    if (h == 0)
     205        h = 0x80000000;
     206    return h;
    193207}
    194208
     
    247261    d = c;
    248262  rep = Rep::create(d, length);
    249 }
    250 
    251 UString::UString(const UString &b)
    252 {
    253   attach(b.rep);
    254263}
    255264
Note: See TracChangeset for help on using the changeset viewer.