Stack: adjust growth factor

The growth factor for the `internal::Stack` helper has not been updated
together with the growth factors used in GenericValue (#130).
This commit is contained in:
Philipp A. Hartmann 2014-09-09 10:45:44 +02:00
parent 7cca533971
commit 296c7db140

View File

@ -98,7 +98,13 @@ private:
template<typename T>
void Expand(size_t count) {
// Only expand the capacity if the current stack exists. Otherwise just create a stack with initial capacity.
size_t newCapacity = (stack_ == 0) ? initialCapacity_ : GetCapacity() * 2;
size_t newCapacity;
if (stack_ == 0)
newCapacity = initialCapacity_;
else {
newCapacity = GetCapacity();
newCapacity += (newCapacity + 1) / 2;
}
size_t newSize = GetSize() + sizeof(T) * count;
if (newCapacity < newSize)
newCapacity = newSize;