Changeset 19178 in webkit for trunk/JavaScriptCore/kjs/ustring.cpp
- Timestamp:
- Jan 26, 2007, 6:31:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.cpp
r17862 r19178 434 434 UString x(a); 435 435 x.expandCapacity(aOffset + length); 436 memcpy(const_cast<UChar *>(a.data() + aSize), b.data(), bSize * sizeof(UChar)); 437 m_rep = Rep::create(a.m_rep, 0, length); 436 if (a.data()) { 437 memcpy(const_cast<UChar *>(a.data() + aSize), b.data(), bSize * sizeof(UChar)); 438 m_rep = Rep::create(a.m_rep, 0, length); 439 } else 440 m_rep = &Rep::null; 438 441 } else if (-bOffset == b.usedPreCapacity() && 4 * bSize >= aSize) { 439 442 // - b reaches the beginning of its buffer so it qualifies for shared prepend … … 442 445 UString y(b); 443 446 y.expandPreCapacity(-bOffset + aSize); 444 memcpy(const_cast<UChar *>(b.data() - aSize), a.data(), aSize * sizeof(UChar)); 445 m_rep = Rep::create(b.m_rep, -aSize, length); 447 if (b.data()) { 448 memcpy(const_cast<UChar *>(b.data() - aSize), a.data(), aSize * sizeof(UChar)); 449 m_rep = Rep::create(b.m_rep, -aSize, length); 450 } else 451 m_rep = &Rep::null; 446 452 } else { 447 453 // a does not qualify for append, and b does not qualify for prepend, gotta make a whole new string 448 454 int newCapacity = expandedSize(length, 0); 449 455 UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * newCapacity)); 450 memcpy(d, a.data(), aSize * sizeof(UChar)); 451 memcpy(d + aSize, b.data(), bSize * sizeof(UChar)); 452 m_rep = Rep::create(d, length); 453 m_rep->capacity = newCapacity; 456 if (d) { 457 memcpy(d, a.data(), aSize * sizeof(UChar)); 458 memcpy(d + aSize, b.data(), bSize * sizeof(UChar)); 459 m_rep = Rep::create(d, length); 460 m_rep->capacity = newCapacity; 461 } else 462 m_rep = &Rep::null; 454 463 } 455 464 }
Note:
See TracChangeset
for help on using the changeset viewer.