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

Unified Diff: Source/wtf/Vector.h

Issue 23604048: Get rid of fastMallocGoodSize() and replace it with something generic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile error. Created 7 years, 3 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/FastMalloc.cpp ('k') | Source/wtf/WTF.h » ('j') | Source/wtf/WTF.h » ('J')
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 4eefbcb3d09419dc98143a5afd1c9bff06b36be6..a2e7895a539517a4e72e68243950a2b96a487b7f 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -28,7 +28,7 @@
#include "wtf/StdLibExtras.h"
#include "wtf/UnusedParam.h"
#include "wtf/VectorTraits.h"
-#include <limits>
+#include "wtf/WTF.h"
#include <utility>
#include <string.h>
@@ -254,12 +254,17 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
class VectorBufferBase {
WTF_MAKE_NONCOPYABLE(VectorBufferBase);
public:
+ size_t roundSize(size_t size)
+ {
+ return (size + 7) & ~7;
+ }
+
void allocateBuffer(size_t newCapacity)
{
ASSERT(newCapacity);
- // Using "unsigned" is not a limitation because Chromium's max malloc() is 2GB even on 64-bit.
- RELEASE_ASSERT(newCapacity <= std::numeric_limits<unsigned>::max() / sizeof(T));
- size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
+ RELEASE_ASSERT(newCapacity <= WTF::QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T));
abarth-chromium 2013/09/07 05:08:24 WTF:: <-- no need for WTF prefix inside WTF.
+ size_t origSizeToAllocate = newCapacity * sizeof(T);
abarth-chromium 2013/09/07 05:08:24 origSizeToAllocate ---> originalSizeToAllocate Pl
+ size_t sizeToAllocate = WTF::QuantizedAllocation::quantizedSize(origSizeToAllocate);
m_capacity = sizeToAllocate / sizeof(T);
m_buffer = static_cast<T*>(fastMalloc(sizeToAllocate));
}
@@ -272,9 +277,9 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
void reallocateBuffer(size_t newCapacity)
{
ASSERT(shouldReallocateBuffer(newCapacity));
- // Using "unsigned" is not a limitation because Chromium's max malloc() is 2GB even on 64-bit.
- RELEASE_ASSERT(newCapacity <= std::numeric_limits<unsigned>::max() / sizeof(T));
- size_t sizeToAllocate = fastMallocGoodSize(newCapacity * sizeof(T));
+ RELEASE_ASSERT(newCapacity <= WTF::QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T));
+ size_t origSizeToAllocate = newCapacity * sizeof(T);
+ size_t sizeToAllocate = WTF::QuantizedAllocation::quantizedSize(origSizeToAllocate);
m_capacity = sizeToAllocate / sizeof(T);
m_buffer = static_cast<T*>(fastRealloc(m_buffer, sizeToAllocate));
}
« no previous file with comments | « Source/wtf/FastMalloc.cpp ('k') | Source/wtf/WTF.h » ('j') | Source/wtf/WTF.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698