Changeset 13066 in webkit for trunk/JavaScriptCore/kjs/property_map.cpp
- Timestamp:
- Feb 28, 2006, 11:19:54 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/property_map.cpp
r12523 r13066 37 37 #define USE_SINGLE_ENTRY 1 38 38 39 // At the time I added USE_SINGLE_ENTRY, the optimization still gave a 1.5%40 // performance boost to the iBench JavaScript benchmark so I didn't remove it.39 // 2/28/2006 ggaren: super accurate JS iBench says that USE_SINGLE_ENTRY is a 40 // 3.2% performance boost. 41 41 42 42 // FIXME: _singleEntry.index is unused. … … 100 100 // Algorithm concepts from Algorithms in C++, Sedgewick. 101 101 102 // This is a method rather than a variable to work around <rdar://problem/4462053> 103 static inline UString::Rep* deletedSentinel() { return reinterpret_cast<UString::Rep*>(-1); } 104 102 105 PropertyMap::~PropertyMap() 103 106 { … … 115 118 for (int i = 0; i < minimumKeysToProcess; i++) { 116 119 UString::Rep *key = entries[i].key; 117 if (key )120 if (key && key != deletedSentinel()) 118 121 key->deref(); 119 else 122 else if (key != deletedSentinel()) 120 123 ++minimumKeysToProcess; 121 124 } … … 140 143 for (int i = 0; i < size; i++) { 141 144 UString::Rep *key = entries[i].key; 142 if (key ) {145 if (key && key != deletedSentinel()) { 143 146 key->deref(); 144 147 entries[i].key = 0; … … 343 346 } 344 347 // If we find the deleted-element sentinel, remember it for use later. 345 if (key == &UString::Rep::null&& !foundDeletedElement) {348 if (key == deletedSentinel() && !foundDeletedElement) { 346 349 foundDeletedElement = true; 347 350 deletedElementIndex = i; … … 358 361 if (foundDeletedElement) { 359 362 i = deletedElementIndex; 360 entries[i].key->deref();361 363 --_table->sentinelCount; 362 364 } … … 387 389 #endif 388 390 while (entries[i].key) { 389 assert(entries[i].key != &UString::Rep::null);391 assert(entries[i].key != deletedSentinel()); 390 392 if (k == 0) 391 393 k = 1 | (h % sizeMask); … … 447 449 if (key) { 448 450 // Don't copy deleted-element sentinels. 449 if (key == &UString::Rep::null) 450 key->deref(); 451 else { 451 if (key != deletedSentinel()) { 452 452 int index = entry.index; 453 453 lastIndexUsed = max(index, lastIndexUsed); … … 509 509 return; 510 510 511 // Replace this one element with the deleted sentinel, 512 // &UString::Rep::null; also set value to 0 and attributes to DontEnum 511 // Replace this one element with the deleted sentinel. Also set value to 0 and attributes to DontEnum 513 512 // to help callers that iterate all keys not have to check for the sentinel. 514 513 key->deref(); 515 key = &UString::Rep::null; 516 key->ref(); 514 key = deletedSentinel(); 517 515 entries[i].key = key; 518 516 entries[i].value = 0; … … 634 632 for (int i = 0; i != size; ++i) { 635 633 UString::Rep *key = entries[i].key; 636 if (key && key != &UString::Rep::null) {634 if (key && key != deletedSentinel()) { 637 635 UString k(key); 638 636 bool fitsInUInt32; … … 730 728 if (!rep) 731 729 continue; 732 if (rep == &UString::Rep::null) {730 if (rep == deletedSentinel()) { 733 731 ++sentinelCount; 734 732 continue;
Note:
See TracChangeset
for help on using the changeset viewer.