summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-07-09 08:52:50 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-07-09 08:52:50 (GMT)
commitce770ef755e2dae405ea3c91bd0dedda2f267716 (patch)
treec035507573d19c49cd8448cc488cbd340a087e91
parentdef00d15449551cd2e98b1f3f5b4199ad8be92c2 (diff)
downloadQt-ce770ef755e2dae405ea3c91bd0dedda2f267716.zip
Qt-ce770ef755e2dae405ea3c91bd0dedda2f267716.tar.gz
Qt-ce770ef755e2dae405ea3c91bd0dedda2f267716.tar.bz2
QRingBuffer micro optimization
-rw-r--r--src/corelib/tools/qringbuffer_p.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index f3daca7..008c068 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -303,6 +303,9 @@ public:
// read an unspecified amount (will read the first buffer)
inline QByteArray read() {
+ if (bufferSize == 0)
+ return QByteArray();
+
// multiple buffers, just take the first one
if (head == 0 && tailBuffer != 0) {
QByteArray qba = buffers.takeFirst();
@@ -325,7 +328,7 @@ public:
// We can avoid by initializing the QRingBuffer with basicBlockSize of 0
// and only using this read() function.
QByteArray qba(readPointer(), nextDataBlockSize());
- buffers.takeFirst();
+ buffers.removeFirst();
head = 0;
if (tailBuffer == 0) {
buffers << QByteArray();