Changeset 38285 in webkit for trunk/JavaScriptCore
- Timestamp:
- Nov 10, 2008, 7:51:24 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r38284 r38285 1 2008-11-10 Maciej Stachowiak <[email protected]> 2 3 Reviewed by Antti Koivisto. 4 5 - Make Vector::clear() release the Vector's memory (1MB savings on membuster) 6 https://bugs.webkit.org/show_bug.cgi?id=22170 7 8 * wtf/Vector.h: 9 (WTF::VectorBufferBase::deallocateBuffer): Set capacity to 0 as 10 well as size, otherwise shrinking capacity to 0 can fail to reset 11 the capacity and thus cause a future crash. 12 (WTF::Vector::~Vector): Shrink size not capacity; we only need 13 to call destructors, the buffer will be freed anyway. 14 (WTF::Vector::clear): Change this to shrinkCapacity(0), not just shrink(0). 15 (WTF::::shrinkCapacity): Use shrink() instead of resize() for case where 16 the size is greater than the new capacity, to work with types that have no 17 default constructor. 18 1 19 2008-11-10 Cameron Zwarich <[email protected]> 2 20 -
trunk/JavaScriptCore/wtf/Vector.h
r38173 r38285 280 280 void deallocateBuffer(T* bufferToDeallocate) 281 281 { 282 if (m_buffer == bufferToDeallocate) 282 if (m_buffer == bufferToDeallocate) { 283 283 m_buffer = 0; 284 m_capacity = 0; 285 } 284 286 fastFree(bufferToDeallocate); 285 287 } … … 443 445 ~Vector() 444 446 { 445 clear();447 if (m_size) shrink(0); 446 448 } 447 449 … … 494 496 void shrinkCapacity(size_t newCapacity); 495 497 496 void clear() { if (m_size) shrink(0); }498 void clear() { shrinkCapacity(0); } 497 499 498 500 template<typename U> void append(const U*, size_t); … … 726 728 return; 727 729 728 resize(min(m_size, newCapacity)); 730 if (newCapacity < size()) 731 shrink(newCapacity); 729 732 730 733 T* oldBuffer = begin();
Note:
See TracChangeset
for help on using the changeset viewer.