Changeset 43048 in webkit
- Timestamp:
- Apr 30, 2009, 2:15:36 AM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r43047 r43048 1 2009-04-30 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Alexey Proskuryakov. 4 5 - speed up string concatenation by reorganizing some simple cases 6 7 0.7% SunSpider speedup 8 9 * runtime/UString.cpp: 10 (JSC::concatenate): Put fast case for appending a single character 11 before the empty string special cases; streamline code a bit to 12 delay computing values that are not needed in the fast path. 13 1 14 2009-04-30 Gavin Barraclough <[email protected]> 2 15 -
trunk/JavaScriptCore/runtime/UString.cpp
r42988 r43048 619 619 620 620 int aSize = a->size(); 621 int bSize = b->size(); 621 622 int aOffset = a->offset; 622 int bSize = b->size();623 int bOffset = b->offset;624 int length = aSize + bSize;625 623 626 624 // possible cases: 625 626 UString::BaseString* aBase = a->baseString(); 627 if (bSize == 1 && aOffset + aSize == aBase->usedCapacity && aOffset + aSize < aBase->capacity) { 628 // b is a single character (common fast case) 629 ++aBase->usedCapacity; 630 a->data()[aSize] = b->data()[0]; 631 return UString::Rep::create(a, 0, aSize + 1); 632 } 627 633 628 634 // a is empty … … 633 639 return a; 634 640 635 UString::BaseString* aBase = a->baseString(); 636 if (bSize == 1 && aOffset + aSize == aBase->usedCapacity && aOffset + length <= aBase->capacity) { 637 // b is a single character (common fast case) 638 aBase->usedCapacity = aOffset + length; 639 a->data()[aSize] = b->data()[0]; 640 return UString::Rep::create(a, 0, length); 641 } 641 int bOffset = b->offset; 642 int length = aSize + bSize; 642 643 643 644 UString::BaseString* bBase = b->baseString();
Note:
See TracChangeset
for help on using the changeset viewer.