Change rdcarray resize strategy to exponential instead of minimal

* Normally this wasn't a problem but in a few cases we were doing lots
  of push_back calls and this caused horrible resize-by-1 behaviour.
* So instead we double the available count (if that's larger than just
  satisfying the request).
This commit is contained in:
baldurk
2017-11-07 19:29:16 +00:00
parent bfc5946227
commit 382639fb3f
+5 -1
View File
@@ -176,7 +176,11 @@ public:
if(s <= capacity())
return;
// for now, just resize exactly to what's needed.
// either double, or allocate what's needed, whichever is bigger. ie. by default we double in
// size but we don't grow exponentially in 2^n to cover a single really large resize
if(size_t(allocatedCount) * 2 > s)
s = size_t(allocatedCount) * 2;
T *newElems = allocate(null_terminator<T>::allocCount(s));
// copy the elements to new storage