diff options
Diffstat (limited to '')
-rw-r--r-- | src/util/ForeignFifoBuffer.hxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/ForeignFifoBuffer.hxx b/src/util/ForeignFifoBuffer.hxx index cd6fb6101..c52846727 100644 --- a/src/util/ForeignFifoBuffer.hxx +++ b/src/util/ForeignFifoBuffer.hxx @@ -204,6 +204,22 @@ public: return n; } + /** + * Move as much data as possible from the specified buffer. + * + * @return the number of items moved + */ + size_type MoveFrom(ForeignFifoBuffer<T> &src) { + auto r = src.Read(); + auto w = Write(); + size_t n = std::min(r.size, w.size); + + std::move(r.data, r.data + n, w.data); + Append(n); + src.Consume(n); + return n; + } + protected: void Shift() { if (head == 0) |