Commit a5709e63 authored by Nicholas Ormrod's avatar Nicholas Ormrod Committed by Alecs King

Improvement fbvector.computePushBackCapacity

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
parent 2d160748
......@@ -1148,14 +1148,16 @@ private:
//
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>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment