Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1530)

Unified Diff: Source/wtf/Vector.h

Issue 1220253004: Implement a fast buffer allocator for Vector, HashTable and StringBuilder Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/WTF.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/Vector.h
diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
index 15d15e3bc9070821b743abd0231669f26ab4b277..f79f116a567af54c3ed5928594e09bfb70242670 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -32,6 +32,7 @@
#include "wtf/VectorTraits.h"
#include <algorithm>
#include <iterator>
+#include <stdio.h>
#include <string.h>
#include <utility>
@@ -319,9 +320,9 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
ASSERT(newCapacity);
size_t sizeToAllocate = allocationSize(newCapacity);
if (hasInlineCapacity)
- m_buffer = Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate);
+ m_buffer = Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate, this);
else
- m_buffer = Allocator::template allocateVectorBacking<T>(sizeToAllocate);
+ m_buffer = Allocator::template allocateVectorBacking<T>(sizeToAllocate, this);
m_capacity = sizeToAllocate / sizeof(T);
}
@@ -330,15 +331,15 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
ASSERT(newCapacity);
size_t sizeToAllocate = allocationSize(newCapacity);
if (hasInlineCapacity)
- m_buffer = Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate);
+ m_buffer = Allocator::template allocateInlineVectorBacking<T>(sizeToAllocate, this);
else
- m_buffer = Allocator::template allocateExpandedVectorBacking<T>(sizeToAllocate);
+ m_buffer = Allocator::template allocateExpandedVectorBacking<T>(sizeToAllocate, this);
m_capacity = sizeToAllocate / sizeof(T);
}
size_t allocationSize(size_t capacity) const
{
- return Allocator::template quantizedSize<T>(capacity);
+ return Allocator::template quantizedSize(capacity, sizeof(T));
}
T* buffer() { return m_buffer; }
@@ -413,7 +414,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
bool expandBuffer(size_t newCapacity)
{
size_t sizeToAllocate = allocationSize(newCapacity);
- if (Allocator::expandVectorBacking(m_buffer, sizeToAllocate)) {
+ if (Allocator::expandVectorBacking(m_buffer, sizeToAllocate + 16)) {
m_capacity = sizeToAllocate / sizeof(T);
return true;
}
@@ -1050,10 +1051,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
#ifdef ANNOTATE_CONTIGUOUS_CONTAINER
size_t oldCapacity = capacity();
#endif
- // The Allocator::isGarbageCollected check is not needed.
- // The check is just a static hint for a compiler to indicate that
- // Base::expandBuffer returns false if Allocator is a DefaultAllocator.
- if (Allocator::isGarbageCollected && Base::expandBuffer(newCapacity)) {
+ if (Base::expandBuffer(newCapacity)) {
ANNOTATE_CHANGE_CAPACITY(begin(), oldCapacity, m_size, capacity());
return;
}
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/WTF.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698