Commit a5ffc5be authored by Milo Yip's avatar Milo Yip

Merge pull request #139 from pah/fixes/stack-growth-factor

Stack: adjust growth factor
parents 7cca5339 296c7db1
......@@ -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;
......
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