Changeset 26958 in webkit for trunk/JavaScriptCore/kjs/property_map.cpp
- Timestamp:
- Oct 24, 2007, 1:14:32 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/property_map.cpp
r26847 r26958 412 412 void PropertyMap::expand() 413 413 { 414 Table *oldTable = m_u.table; 415 int oldTableSize = m_usingTable ? oldTable->size : 0; 416 rehash(oldTableSize ? oldTableSize * 2 : 16); 414 if (!m_usingTable) 415 createTable(); 416 else 417 rehash(m_u.table->size * 2); 417 418 } 418 419 419 420 void PropertyMap::rehash() 420 421 { 422 ASSERT(m_usingTable); 421 423 ASSERT(m_u.table); 422 424 ASSERT(m_u.table->size); … … 424 426 } 425 427 426 void PropertyMap::rehash(int newTableSize) 427 { 428 void PropertyMap::createTable() 429 { 430 const int newTableSize = 16; 431 432 ASSERT(!m_usingTable); 433 428 434 checkConsistency(); 429 435 … … 432 438 #endif 433 439 434 Table *oldTable = m_usingTable ? m_u.table : 0; 435 int oldTableSize = m_usingTable ? oldTable->size : 0; 436 int oldTableKeyCount = m_usingTable ? oldTable->keyCount : 0; 437 438 m_u.table = (Table *)fastCalloc(1, sizeof(Table) + (newTableSize - 1) * sizeof(Entry) ); 440 m_u.table = (Table *)fastCalloc(1, sizeof(Table) + (newTableSize - 1) * sizeof(Entry)); 439 441 m_u.table->size = newTableSize; 440 442 m_u.table->sizeMask = newTableSize - 1; 441 m_u.table->keyCount = oldTableKeyCount;442 443 m_usingTable = true; 443 444 … … 447 448 insert(key, oldSingleEntryValue, m_singleEntryAttributes, 0); 448 449 m_singleEntryKey = 0; 449 // update the count, because single entries don't count towards 450 // the table key count 451 ++m_u.table->keyCount; 452 ASSERT(m_u.table->keyCount == 1); 453 } 454 #endif 450 m_u.table->keyCount = 1; 451 } 452 #endif 453 454 checkConsistency(); 455 } 456 457 void PropertyMap::rehash(int newTableSize) 458 { 459 ASSERT(!m_singleEntryKey); 460 ASSERT(m_u.table); 461 ASSERT(m_usingTable); 462 463 checkConsistency(); 464 465 Table* oldTable = m_u.table; 466 int oldTableSize = oldTable->size; 467 int oldTableKeyCount = oldTable->keyCount; 468 469 m_u.table = (Table *)fastCalloc(1, sizeof(Table) + (newTableSize - 1) * sizeof(Entry)); 470 m_u.table->size = newTableSize; 471 m_u.table->sizeMask = newTableSize - 1; 472 m_u.table->keyCount = oldTableKeyCount; 455 473 456 474 int lastIndexUsed = 0;
Note:
See TracChangeset
for help on using the changeset viewer.