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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 template<typename U> bool contains(const U&) const; 668 template<typename U> bool contains(const U&) const;
669 template<typename U> size_t find(const U&) const; 669 template<typename U> size_t find(const U&) const;
670 template<typename U> size_t reverseFind(const U&) const; 670 template<typename U> size_t reverseFind(const U&) const;
671 671
672 void shrink(size_t size); 672 void shrink(size_t size);
673 void grow(size_t size); 673 void grow(size_t size);
674 void resize(size_t size); 674 void resize(size_t size);
675 void reserveCapacity(size_t newCapacity); 675 void reserveCapacity(size_t newCapacity);
676 void reserveInitialCapacity(size_t initialCapacity); 676 void reserveInitialCapacity(size_t initialCapacity);
677 void shrinkToFit() { shrinkCapacity(size()); } 677 void shrinkToFit() { shrinkCapacity(size()); }
678 void shrinkToReasonableCapacity()
679 {
680 if (size() * 2 < capacity())
681 shrinkCapacity(size() + size() / 4 + 1);
abarth-chromium 2014/04/17 19:21:36 Is there a problem with integer overflow in this c
682 }
678 683
679 void clear() { shrinkCapacity(0); } 684 void clear() { shrinkCapacity(0); }
680 685
681 template<typename U> void append(const U*, size_t); 686 template<typename U> void append(const U*, size_t);
682 template<typename U> void append(const U&); 687 template<typename U> void append(const U&);
683 template<typename U> void uncheckedAppend(const U& val); 688 template<typename U> void uncheckedAppend(const U& val);
684 template<typename U, size_t otherCapacity, typename V> void appendVector (const Vector<U, otherCapacity, V>&); 689 template<typename U, size_t otherCapacity, typename V> void appendVector (const Vector<U, otherCapacity, V>&);
685 690
686 template<typename U> void insert(size_t position, const U*, size_t); 691 template<typename U> void insert(size_t position, const U*, size_t);
687 template<typename U> void insert(size_t position, const U&); 692 template<typename U> void insert(size_t position, const U&);
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 } 1206 }
1202 if (this->hasOutOfLineBuffer()) 1207 if (this->hasOutOfLineBuffer())
1203 Allocator::markNoTracing(visitor, buffer()); 1208 Allocator::markNoTracing(visitor, buffer());
1204 } 1209 }
1205 1210
1206 } // namespace WTF 1211 } // namespace WTF
1207 1212
1208 using WTF::Vector; 1213 using WTF::Vector;
1209 1214
1210 #endif // WTF_Vector_h 1215 #endif // WTF_Vector_h
OLDNEW
« 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