diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-07-09 08:52:50 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-07-09 08:52:50 (GMT) |
commit | ce770ef755e2dae405ea3c91bd0dedda2f267716 (patch) | |
tree | c035507573d19c49cd8448cc488cbd340a087e91 | |
parent | def00d15449551cd2e98b1f3f5b4199ad8be92c2 (diff) | |
download | Qt-ce770ef755e2dae405ea3c91bd0dedda2f267716.zip Qt-ce770ef755e2dae405ea3c91bd0dedda2f267716.tar.gz Qt-ce770ef755e2dae405ea3c91bd0dedda2f267716.tar.bz2 |
QRingBuffer micro optimization
-rw-r--r-- | src/corelib/tools/qringbuffer_p.h | 5 |
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(); |