QRingBuffer: restrict QRingChunk::toByteArray() calls to rvalue *this
It's only user, QRingBuffer::read(), calls it on an rvalue, so we don't need the lvalue overload, and we can devil-may-care-like just std::move(chunk) in the non-isShared() case. Change-Id: I99c16862f5586125c6346ce5f969dc735de738b8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
b01c05ef9b
commit
e381288146
@ -62,7 +62,7 @@ void QRingChunk::detach()
|
|||||||
tailOffset = chunkSize;
|
tailOffset = chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray QRingChunk::toByteArray()
|
QByteArray QRingChunk::toByteArray() &&
|
||||||
{
|
{
|
||||||
if (headOffset != 0 || tailOffset != chunk.size()) {
|
if (headOffset != 0 || tailOffset != chunk.size()) {
|
||||||
if (isShared())
|
if (isShared())
|
||||||
@ -79,7 +79,7 @@ QByteArray QRingChunk::toByteArray()
|
|||||||
chunk.resize(tailOffset);
|
chunk.resize(tailOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunk;
|
return std::move(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
return !chunk.isDetached();
|
return !chunk.isDetached();
|
||||||
}
|
}
|
||||||
Q_CORE_EXPORT void detach();
|
Q_CORE_EXPORT void detach();
|
||||||
QByteArray toByteArray();
|
QByteArray toByteArray() &&;
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
inline qsizetype head() const
|
inline qsizetype head() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user