summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2015-10-17 20:13:40 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2015-10-20 14:44:21 +0000
commit43b6101df39c04fc8bac0e335c28e4ebcc779df4 (patch)
tree8721a646d156cb48b21bc8a988fa20a0118a4a27
parentbafbf3b872103409370fbda43a2ce3ad153a33f4 (diff)
QRingBuffer: improve skip() performance
Use free() instead of read(0, length) call. Change-Id: I284e2099a3fb639cb40525ae2ca7fea0d09a620f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-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 3a5ae1c4cc..96c4f9acb6 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -119,7 +119,10 @@ public:
Q_CORE_EXPORT void append(const QByteArray &qba);
inline qint64 skip(qint64 length) {
- return read(0, length);
+ qint64 bytesToSkip = qMin(length, bufferSize);
+
+ free(bytesToSkip);
+ return bytesToSkip;
}
Q_CORE_EXPORT qint64 readLine(char *data, qint64 maxLength);