summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer_p.h
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2014-08-27 16:43:52 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2014-11-26 07:21:14 +0100
commitae9ee18cad4e9485ad53ac41916d7e2e77c3cbd1 (patch)
tree922b5db111fa81e01555d96eefd60ead3e25f111 /src/corelib/tools/qringbuffer_p.h
parent13b139d0283a866dcf73bcca9405f5348a627954 (diff)
QRingBuffer: optimize memory usage
QByteArray resizing behavior is to preallocate a certain amount of memory for future growth. Make QRingBuffer aware of the extra capacity in QByteArray. Change-Id: I68310d5783fbc32e4fd5075ed3269ce6b7128a92 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qringbuffer_p.h')
-rw-r--r--src/corelib/tools/qringbuffer_p.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 27d0791bd2..8fe56323a3 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -113,7 +113,7 @@ public:
// if need buffer reallocation
if (tail + bytes > buffers.last().size()) {
- if (tail >= basicBlockSize) {
+ if (tail + bytes > buffers.last().capacity() && tail >= basicBlockSize) {
// shrink this buffer to its current size
buffers.last().resize(tail);