Changeset 31032 in webkit for trunk/JavaScriptCore
- Timestamp:
- Mar 13, 2008, 11:32:07 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r31030 r31032 1 2008-03-13 Beth Dakin <[email protected]> 2 3 Reviewed by Geoff. 4 5 Adding new functionality to Vector. Currently all of the shrink and 6 resize functions on Vector only shrink the size of the Vector, not 7 the capacity. For the Vector to take up as little memory as 8 possible, though, it is necessary to be able to shrink the capacity 9 as well. So this patch adds that functionality. 10 11 I need this for a speed up I am working on, and Geoff wants to use 12 it in a speed up he is working on also, so he asked me to commit it 13 now. 14 15 * wtf/Vector.h: 16 (WTF::VectorBufferBase::allocateBuffer): 17 (WTF::::shrinkCapacity): 18 1 19 2008-03-13 Simon Hausmann <[email protected]> 2 20 -
trunk/JavaScriptCore/wtf/Vector.h
r30593 r31032 246 246 void allocateBuffer(size_t newCapacity) 247 247 { 248 ASSERT(newCapacity >= m_capacity);249 248 m_capacity = newCapacity; 250 249 if (newCapacity > std::numeric_limits<size_t>::max() / sizeof(T)) … … 456 455 void resize(size_t size); 457 456 void reserveCapacity(size_t newCapacity); 457 void shrinkCapacity(size_t newCapacity); 458 458 459 459 void clear() { if (m_size) shrink(0); } … … 657 657 m_buffer.allocateBuffer(newCapacity); 658 658 TypeOperations::move(oldBuffer, oldEnd, begin()); 659 m_buffer.deallocateBuffer(oldBuffer); 660 } 661 662 template<typename T, size_t inlineCapacity> 663 void Vector<T, inlineCapacity>::shrinkCapacity(size_t newCapacity) 664 { 665 if (newCapacity >= capacity()) 666 return; 667 668 T* oldBuffer = begin(); 669 if (newCapacity > 0) { 670 T* oldEnd = end(); 671 m_buffer.allocateBuffer(newCapacity); 672 TypeOperations::move(oldBuffer, oldEnd, begin()); 673 } 674 m_size = min(m_size, newCapacity); 659 675 m_buffer.deallocateBuffer(oldBuffer); 660 676 }
Note:
See TracChangeset
for help on using the changeset viewer.