diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/str.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/str.cpp b/common/str.cpp index 5e771c8b4d..50b9bdb879 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -151,7 +151,11 @@ void String::ensureCapacity(uint32 new_size, bool keep_old) { // We need to allocate storage on the heap! // Compute a suitable new capacity limit - newCapacity = MAX(curCapacity * 2, computeCapacity(new_size+1)); + // If the current capacity is sufficient we use the same capacity + if (new_size < curCapacity) + newCapacity = curCapacity; + else + newCapacity = MAX(curCapacity * 2, computeCapacity(new_size+1)); // Allocate new storage newStorage = new char[newCapacity]; |
