From 43b6101df39c04fc8bac0e335c28e4ebcc779df4 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 17 Oct 2015 20:13:40 +0300 Subject: [PATCH] QRingBuffer: improve skip() performance Use free() instead of read(0, length) call. Change-Id: I284e2099a3fb639cb40525ae2ca7fea0d09a620f Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qringbuffer_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);