Summary:
See the github pull request at https://github.com/facebook/folly/issues/135
Important optimizations: remove one of the branches and change ##empty()## to ##capacity()==0##
Test Plan:
Ran extended fbvector test suite (re-enabled in experimental/njormrod)
Also
fbconfig -r folly && fbmake runtests
Reviewed By: markisaa@fb.com
Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@, yfeldblum
FB internal diff:
D1869112
Tasks:
6338531
Signature: t1:
1869112:
1424823901:
d2d7331aef82edad1e8c159005cc1c7185550d0c
//
size_type computePushBackCapacity() const {
- return empty() ? std::max(64 / sizeof(T), size_type(1))
- : capacity() < folly::jemallocMinInPlaceExpandable / sizeof(T)
- ? capacity() * 2
- : sizeof(T) > folly::jemallocMinInPlaceExpandable / 2 && capacity() == 1
- ? 2
- : capacity() > 4096 * 32 / sizeof(T)
- ? capacity() * 2
- : (capacity() * 3 + 1) / 2;
+ if (capacity() == 0) {
+ return std::max(64 / sizeof(T), size_type(1));
+ }
+ if (capacity() < folly::jemallocMinInPlaceExpandable / sizeof(T)) {
+ return capacity() * 2;
+ }
+ if (capacity() > 4096 * 32 / sizeof(T)) {
+ return capacity() * 2;
+ }
+ return (capacity() * 3 + 1) / 2;
}
template <class... Args>