Changeset 2769 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Nov 19, 2002, 5:23:02 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r2762 r2769 37 37 #include "ustring.h" 38 38 #include "operations.h" 39 #include "identifier.h" 39 40 #include <math.h> 40 41 … … 115 116 116 117 UChar UChar::null((char)0); 117 UString::Rep UString::Rep::null = { 0, 0, 0, 1 };118 UString::Rep UString::Rep::empty = { 0, 0, 0, 1 };118 UString::Rep UString::Rep::null = { 0, 0, 0, 1, 1 }; 119 UString::Rep UString::Rep::empty = { 0, 0, 0, 1, 1 }; 119 120 UString UString::null; 120 121 const int normalStatBufferSize = 4096; … … 163 164 r->capacity = l; 164 165 r->rc = 1; 166 r->_hash = 0; 165 167 166 168 return r; 169 } 170 171 void UString::Rep::destroy() 172 { 173 if (capacity == capacityForIdentifier) 174 Identifier::aboutToDestroyUStringRep(this); 175 delete [] dat; 176 delete this; 177 } 178 179 void UString::Rep::computeHash() const 180 { 181 int length = len; 182 int prefixLength = length < 8 ? length : 8; 183 int suffixPosition = length < 16 ? 8 : length - 8; 184 185 unsigned h = length; 186 for (int i = 0; i < prefixLength; i++) 187 h = 127 * h + dat[i].unicode(); 188 for (int i = suffixPosition; i < length; i++) 189 h = 127 * h + dat[i].unicode(); 190 if (h == 0) 191 h = 0x80000000; 192 _hash = h; 167 193 } 168 194 … … 329 355 memcpy(rep->dat+l, t.data(), tLen * sizeof(UChar)); 330 356 rep->len = newLen; 357 rep->_hash = 0; 331 358 return *this; 332 359 } … … 389 416 int l = c ? strlen(c) : 0; 390 417 UChar *d; 391 if (rep->rc == 1 && l < rep->capacity) {418 if (rep->rc == 1 && l <= rep->capacity) { 392 419 d = rep->dat; 420 rep->_hash = 0; 393 421 } else { 394 422 release();
Note:
See TracChangeset
for help on using the changeset viewer.