Changeset 2772 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Nov 19, 2002, 6:35:01 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r2769 r2772 165 165 r->rc = 1; 166 166 r->_hash = 0; 167 168 167 return r; 169 168 } … … 172 171 { 173 172 if (capacity == capacityForIdentifier) 174 Identifier:: aboutToDestroyUStringRep(this);173 Identifier::remove(this); 175 174 delete [] dat; 176 175 delete this; 177 176 } 178 177 179 void UString::Rep::computeHash() const 180 { 181 int length = len; 178 unsigned UString::Rep::computeHash(const UChar *s, int length) 179 { 182 180 int prefixLength = length < 8 ? length : 8; 183 181 int suffixPosition = length < 16 ? 8 : length - 8; … … 185 183 unsigned h = length; 186 184 for (int i = 0; i < prefixLength; i++) 187 h = 127 * h + dat[i].unicode();185 h = 127 * h + s[i].unicode(); 188 186 for (int i = suffixPosition; i < length; i++) 189 h = 127 * h + dat[i].unicode();187 h = 127 * h + s[i].unicode(); 190 188 if (h == 0) 191 189 h = 0x80000000; 192 _hash = h; 190 return h; 191 } 192 193 unsigned 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; 193 207 } 194 208 … … 247 261 d = c; 248 262 rep = Rep::create(d, length); 249 }250 251 UString::UString(const UString &b)252 {253 attach(b.rep);254 263 } 255 264
Note:
See TracChangeset
for help on using the changeset viewer.