From cfeba45c35fff8e7afc083e566b817578a919c0a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 23 Apr 2014 18:37:49 -0700 Subject: [PATCH] Let the buffer grow as it pleases. --- format.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/format.cc b/format.cc index 671cc017..ab2a0ea3 100644 --- a/format.cc +++ b/format.cc @@ -360,7 +360,9 @@ void fmt::BasicWriter::FormatDouble( GrowBuffer(n); return; } - buffer_.reserve(n >= 0 ? offset + n + 1 : 2 * buffer_.capacity()); + // If n is negative we ask to increase the capacity by at least 1, + // but as std::vector, the buffer grows exponentially. + buffer_.reserve(n >= 0 ? offset + n + 1 : buffer_.capacity() + 1); } }