diff options
-rw-r--r-- | cppe/include/IceE/Buffer.h | 11 | ||||
-rw-r--r-- | cppe/src/IceE/Buffer.cpp | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/cppe/include/IceE/Buffer.h b/cppe/include/IceE/Buffer.h index 5cf1a7fcfd5..37f98a6a905 100644 --- a/cppe/include/IceE/Buffer.h +++ b/cppe/include/IceE/Buffer.h @@ -129,7 +129,15 @@ public: // current size. This is to avoid holding on too much // memory if it's not needed anymore. // - reserve(_size); + if(++_shrinkCounter > 2) + { + reserve(_size); + _shrinkCounter = 0; + } + } + else + { + _shrinkCounter = 0; } _size = 0; } @@ -161,6 +169,7 @@ public: pointer _buf; size_type _size; size_type _capacity; + int _shrinkCounter; #ifdef ICE_SMALL_MESSAGE_BUFFER_OPTIMIZATION // diff --git a/cppe/src/IceE/Buffer.cpp b/cppe/src/IceE/Buffer.cpp index ae7563a7aa5..c6b758b3a5b 100644 --- a/cppe/src/IceE/Buffer.cpp +++ b/cppe/src/IceE/Buffer.cpp @@ -68,6 +68,7 @@ IceInternal::Buffer::Container::swap(Container& other) std::swap(_size, other._size); std::swap(_capacity, other._capacity); + std::swap(_shrinkCounter, other._shrinkCounter); } void |