diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-05-05 17:45:58 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-08-01 10:51:21 +0200 |
commit | 246e7125485570416560d6a8503f785a31be1b3e (patch) | |
tree | 916d2786cb0725fbd117def18e372d2b1772f941 /src | |
parent | 5d7be66fd742e694576ce722aa6e0766c23942f7 (diff) |
Move-enable QByteDataBuffer::{append,prepend}
Change-Id: I2fd342465475e3a694c8459a54957149f8b418a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qbytedata_p.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/corelib/text/qbytedata_p.h b/src/corelib/text/qbytedata_p.h index 108aec72ac..551edc8b1b 100644 --- a/src/corelib/text/qbytedata_p.h +++ b/src/corelib/text/qbytedata_p.h @@ -53,6 +53,7 @@ #include <QtCore/private/qglobal_p.h> #include <qbytearray.h> +#include <QtCore/qlist.h> QT_BEGIN_NAMESPACE @@ -90,25 +91,48 @@ public: popFront(buffers[bufferCount() - other.bufferCount()], other.firstPos); } + inline void append(QByteDataBuffer &&other) + { + if (other.isEmpty()) + return; + + auto otherBufferCount = other.bufferCount(); + auto otherByteAmount = other.byteAmount(); + buffers.append(std::move(other.buffers)); + bufferCompleteSize += otherByteAmount; + + if (other.firstPos > 0) + popFront(buffers[bufferCount() - otherBufferCount], other.firstPos); + } inline void append(const QByteArray& bd) { + append(QByteArray(bd)); + } + + inline void append(QByteArray &&bd) + { if (bd.isEmpty()) return; - buffers.append(bd); bufferCompleteSize += bd.size(); + buffers.append(std::move(bd)); } inline void prepend(const QByteArray& bd) { + prepend(QByteArray(bd)); + } + + inline void prepend(QByteArray &&bd) + { if (bd.isEmpty()) return; squeezeFirst(); - buffers.prepend(bd); bufferCompleteSize += bd.size(); + buffers.prepend(std::move(bd)); } // return the first QByteData. User of this function has to free() its .data! |