From f083830b8de106ed51d39242008215e9ea2179b2 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 13 Apr 2016 14:45:11 +0300 Subject: CoreLib: use const (and const APIs) more For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira --- src/corelib/tools/qringbuffer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib/tools/qringbuffer.cpp') diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index db2004dfd9..4a2dfdec2b 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -74,14 +74,14 @@ void QRingBuffer::free(qint64 bytes) Q_ASSERT(bytes <= bufferSize); while (bytes > 0) { - const qint64 blockSize = buffers.first().size() - head; + const qint64 blockSize = buffers.constFirst().size() - head; if (tailBuffer == 0 || blockSize > bytes) { // keep a single block around if it does not exceed // the basic block size, to avoid repeated allocations // between uses of the buffer if (bufferSize <= bytes) { - if (buffers.first().size() <= basicBlockSize) { + if (buffers.constFirst().size() <= basicBlockSize) { bufferSize = 0; head = tail = 0; } else { @@ -114,8 +114,8 @@ char *QRingBuffer::reserve(qint64 bytes) } else { const qint64 newSize = bytes + tail; // if need buffer reallocation - if (newSize > buffers.last().size()) { - if (newSize > buffers.last().capacity() && (tail >= basicBlockSize + if (newSize > buffers.constLast().size()) { + if (newSize > buffers.constLast().capacity() && (tail >= basicBlockSize || newSize >= MaxByteArraySize)) { // shrink this buffer to its current size buffers.last().resize(tail); @@ -180,7 +180,7 @@ void QRingBuffer::chop(qint64 bytes) // the basic block size, to avoid repeated allocations // between uses of the buffer if (bufferSize <= bytes) { - if (buffers.first().size() <= basicBlockSize) { + if (buffers.constFirst().size() <= basicBlockSize) { bufferSize = 0; head = tail = 0; } else { @@ -198,7 +198,7 @@ void QRingBuffer::chop(qint64 bytes) bytes -= tail; buffers.removeLast(); --tailBuffer; - tail = buffers.last().size(); + tail = buffers.constLast().size(); } } -- cgit v1.2.3