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

Unified Diff: Source/wtf/Vector.h

Issue 239603005: Add method Vector::shrinkToReasonableCapacity() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove UNLIKELY macro from condition. Created 6 years, 8 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 | « no previous file | no next file » | 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 ab18fe5fe421fae435d5627c5adcc6542d981021..e42413f9a46fa79d8cc96824953218af7d0b029b 100644
--- a/Source/wtf/Vector.h
+++ b/Source/wtf/Vector.h
@@ -675,6 +675,11 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
void reserveCapacity(size_t newCapacity);
void reserveInitialCapacity(size_t initialCapacity);
void shrinkToFit() { shrinkCapacity(size()); }
+ void shrinkToReasonableCapacity()
+ {
+ if (size() * 2 < capacity())
+ shrinkCapacity(size() + size() / 4 + 1);
abarth-chromium 2014/04/17 19:21:36 Is there a problem with integer overflow in this c
+ }
void clear() { shrinkCapacity(0); }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698