Changeset 29639 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Jan 18, 2008, 1:05:16 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r27859 r29639 78 78 } 79 79 80 // we'd rather not do shared substring append for small strings, since81 // this runs too much risk of a tiny initial string holding down a82 // huge buffer. This is also tuned to match the extra cost size, so we83 // don't ever share a buffer that wouldn't be over the extra cost84 // threshold already.85 // FIXME: this should be size_t but that would cause warnings until we86 // fix UString sizes to be size_t instad of int87 static const int minShareSize = Collector::minExtraCostSize / sizeof(UChar);88 89 80 COMPILE_ASSERT(sizeof(UChar) == 2, uchar_is_2_bytes) 90 81 … … 174 165 // Hack here to avoid a global with a constructor; point to an unsigned short instead of a UChar. 175 166 static unsigned short almostUChar; 176 UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, &UString::Rep::null, 0, 0, 0, 0, 0 };177 UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, reinterpret_cast<UChar*>(&almostUChar), 0, 0, 0, 0 };167 UString::Rep UString::Rep::null = { 0, 0, 1, 0, 0, &UString::Rep::null, 0, 0, 0, 0, 0, 0 }; 168 UString::Rep UString::Rep::empty = { 0, 0, 1, 0, 0, &UString::Rep::empty, 0, reinterpret_cast<UChar*>(&almostUChar), 0, 0, 0, 0 }; 178 169 const int normalStatBufferSize = 4096; 179 170 static char *statBuffer = 0; // FIXME: This buffer is never deallocated. … … 202 193 r->isIdentifier = 0; 203 194 r->baseString = r; 195 r->reportedCost = 0; 204 196 r->buf = d; 205 197 r->usedCapacity = l; … … 231 223 r->isIdentifier = 0; 232 224 r->baseString = base.releaseRef(); 225 r->reportedCost = 0; 233 226 r->buf = 0; 234 227 r->usedCapacity = 0; … … 498 491 } else 499 492 m_rep = &Rep::null; 500 } else if (-bOffset == b.usedPreCapacity() && bSize >= minShareSize && 4 * bSize >= aSize) {493 } else if (-bOffset == b.usedPreCapacity() && bSize >= minShareSize && 4 * bSize >= aSize) { 501 494 // - b reaches the beginning of its buffer so it qualifies for shared prepend 502 495 // - also, it's at least a quarter the length of a - prepending to a much shorter … … 1291 1284 1292 1285 1286 1293 1287 } // namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.