diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2021-12-13 12:03:51 +0100 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2021-12-15 18:36:00 +0000 |
| commit | 758a830f7ef23ebea542bc6dad4490b29e22bab8 (patch) | |
| tree | 84211dc469328fa6118f859638e04f9e8d974ef8 /src/corelib/tools/qringbuffer.cpp | |
| parent | 63a35898f4990963fe91acd565df49111a281fa4 (diff) | |
QRingBuffer: overload append() for rvalues
The majority of append() callers in QtBase pass rvalues, so overload
append() to avoid the need for manipulating QBA's atomic ref counts.
Also adjust a caller that could pass by rvalue, but didn't, to do so.
Pick-to: 6.3
Change-Id: I3d9e60b0d04ef837bfdc526e1f0f691a151006f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
| -rw-r--r-- | src/corelib/tools/qringbuffer.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp index 09b0336145f..d46dcdffdff 100644 --- a/src/corelib/tools/qringbuffer.cpp +++ b/src/corelib/tools/qringbuffer.cpp @@ -363,6 +363,21 @@ void QRingBuffer::append(const QByteArray &qba) bufferSize += qba.size(); } +/*! + \internal + + Append a new buffer to the end +*/ +void QRingBuffer::append(QByteArray &&qba) +{ + const auto qbaSize = qba.size(); + if (bufferSize != 0 || buffers.isEmpty()) + buffers.emplace_back(std::move(qba)); + else + buffers.last().assign(std::move(qba)); + bufferSize += qbaSize; +} + qint64 QRingBuffer::readLine(char *data, qint64 maxLength) { Q_ASSERT(data != nullptr && maxLength > 1); |
