Changeset 36778 in webkit for trunk/JavaScriptCore/kjs/JSArray.cpp
- Timestamp:
- Sep 22, 2008, 2:04:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSArray.cpp
r36726 r36778 312 312 if (increaseVectorLength(i + 1)) { 313 313 storage = m_storage; 314 ++storage->m_numValuesInVector;315 314 storage->m_vector[i] = value; 315 if (++storage->m_numValuesInVector == storage->m_length) 316 m_fastAccessCutoff = storage->m_length; 316 317 checkConsistency(); 317 318 } else … … 509 510 } 510 511 512 JSValue* JSArray::pop() 513 { 514 checkConsistency(); 515 516 unsigned length = m_storage->m_length; 517 if (!length) 518 return jsUndefined(); 519 520 --length; 521 522 JSValue* result; 523 524 if (m_fastAccessCutoff > length) { 525 JSValue*& valueSlot = m_storage->m_vector[length]; 526 result = valueSlot; 527 ASSERT(result); 528 valueSlot = 0; 529 --m_storage->m_numValuesInVector; 530 m_fastAccessCutoff = length; 531 } else if (length < m_storage->m_vectorLength) { 532 JSValue*& valueSlot = m_storage->m_vector[length]; 533 result = valueSlot; 534 valueSlot = 0; 535 if (result) 536 --m_storage->m_numValuesInVector; 537 else 538 result = jsUndefined(); 539 } else { 540 result = jsUndefined(); 541 if (SparseArrayValueMap* map = m_storage->m_sparseValueMap) { 542 SparseArrayValueMap::iterator it = map->find(length); 543 if (it != map->end()) { 544 result = it->second; 545 map->remove(it); 546 if (map->isEmpty()) { 547 delete map; 548 m_storage->m_sparseValueMap = 0; 549 } 550 } 551 } 552 } 553 554 m_storage->m_length = length; 555 556 checkConsistency(); 557 558 return result; 559 } 560 561 void JSArray::push(ExecState* exec, JSValue* value) 562 { 563 checkConsistency(); 564 565 if (m_storage->m_length < m_storage->m_vectorLength) { 566 ASSERT(!m_storage->m_vector[m_storage->m_length]); 567 m_storage->m_vector[m_storage->m_length] = value; 568 if (++m_storage->m_numValuesInVector == ++m_storage->m_length) 569 m_fastAccessCutoff = m_storage->m_length; 570 checkConsistency(); 571 return; 572 } 573 574 if (m_storage->m_length < MIN_SPARSE_ARRAY_INDEX) { 575 SparseArrayValueMap* map = m_storage->m_sparseValueMap; 576 if (!map || map->isEmpty()) { 577 if (increaseVectorLength(m_storage->m_length + 1)) { 578 m_storage->m_vector[m_storage->m_length] = value; 579 if (++m_storage->m_numValuesInVector == ++m_storage->m_length) 580 m_fastAccessCutoff = m_storage->m_length; 581 checkConsistency(); 582 return; 583 } 584 checkConsistency(); 585 throwOutOfMemoryError(exec); 586 return; 587 } 588 } 589 590 putSlowCase(exec, m_storage->m_length++, value); 591 } 592 511 593 void JSArray::mark() 512 594 {
Note:
See TracChangeset
for help on using the changeset viewer.