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

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: Add missed WTF_EXPORT. 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/QuantizedAllocation.cpp ('k') | Source/wtf/WTF.h » ('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 a49fb68864c175df5ee972dd0b8fdea8f42aedf8..2f4403bd39c08cb9ddb6c6bb4c0ff7087eb23aeb 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -25,10 +25,10 @@
#include "wtf/FastAllocBase.h"
#include "wtf/Noncopyable.h"
#include "wtf/NotFound.h"
+#include "wtf/QuantizedAllocation.h"
#include "wtf/StdLibExtras.h"
#include "wtf/UnusedParam.h"
#include "wtf/VectorTraits.h"
-#include <limits>
#include <utility>
#include <string.h>
@@ -257,9 +257,9 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
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 <= QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T));
+ size_t originalSizeToAllocate = newCapacity * sizeof(T);
+ size_t sizeToAllocate = QuantizedAllocation::quantizedSize(originalSizeToAllocate);
m_capacity = sizeToAllocate / sizeof(T);
m_buffer = static_cast<T*>(fastMalloc(sizeToAllocate));
}
@@ -272,9 +272,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 <= QuantizedAllocation::kMaxUnquantizedAllocation / sizeof(T));
+ size_t originalSizeToAllocate = newCapacity * sizeof(T);
+ size_t sizeToAllocate = QuantizedAllocation::quantizedSize(originalSizeToAllocate);
m_capacity = sizeToAllocate / sizeof(T);
m_buffer = static_cast<T*>(fastRealloc(m_buffer, sizeToAllocate));
}
« no previous file with comments | « Source/wtf/QuantizedAllocation.cpp ('k') | Source/wtf/WTF.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698