From 296c7db1402ec4357d69dc502302d83515f8b4b5 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 9 Sep 2014 10:45:44 +0200 Subject: [PATCH] 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). --- include/rapidjson/internal/stack.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 294b51a..d4d3c92 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -98,7 +98,13 @@ private: template 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;