Index: Source/wtf/Vector.h |
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h |
index 0912c2cebc7469b36e1d680028fdbf8b36d0dac0..584117266813fbcd8501c2bfa417e1deb6a695ff 100644 |
--- a/Source/wtf/Vector.h |
+++ b/Source/wtf/Vector.h |
@@ -359,6 +359,16 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
Allocator::backingFree(bufferToDeallocate); |
} |
+ bool expandBuffer(size_t newCapacity) |
+ { |
+ size_t sizeToAllocate = allocationSize(newCapacity); |
+ if (Allocator::backingExpand(m_buffer, sizeToAllocate)) { |
+ m_capacity = sizeToAllocate / sizeof(T); |
+ return true; |
+ } |
+ return false; |
+ } |
+ |
void resetBufferPointer() |
{ |
m_buffer = 0; |
@@ -428,6 +438,21 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
reallyDeallocateBuffer(bufferToDeallocate); |
} |
+ bool expandBuffer(size_t newCapacity) |
+ { |
+ if (newCapacity <= inlineCapacity) |
tkent
2014/11/14 03:54:25
Is this check necessary? The callsite already has
haraken
2014/11/14 04:32:45
Removed.
|
+ return true; |
+ if (m_buffer == inlineBuffer()) |
+ return false; |
+ |
+ size_t sizeToAllocate = allocationSize(newCapacity); |
+ if (Allocator::backingExpand(m_buffer, sizeToAllocate)) { |
+ m_capacity = sizeToAllocate / sizeof(T); |
+ return true; |
+ } |
+ return false; |
+ } |
+ |
void resetBufferPointer() |
{ |
m_buffer = inlineBuffer(); |
@@ -949,6 +974,8 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE; |
return; |
T* oldBuffer = begin(); |
T* oldEnd = end(); |
+ if (Base::expandBuffer(newCapacity)) |
tkent
2014/11/14 03:54:25
I'm afraid this change causes performance regressi
haraken
2014/11/14 04:32:45
I observe no regression in parser benchmarks that
|
+ return; |
Base::allocateBuffer(newCapacity); |
TypeOperations::move(oldBuffer, oldEnd, begin()); |
Base::deallocateBuffer(oldBuffer); |