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

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: 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..47302cc0b399e8c4d565030a1bd36ef394c9f8b7 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())
+ shrinkToFit();
danakj 2014/04/15 22:21:40 How about: shrinkCapacity(size() * 2)? So a serie
ostap 2014/04/15 22:46:34 I thought that shrinkToFit() would be better for m
danakj 2014/04/15 22:53:25 Oh, yes I agree. I didn't read the method far enou
+ }
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