diff --git a/src/util/ForeignFifoBuffer.hxx b/src/util/ForeignFifoBuffer.hxx index e11db2010..c811d9b02 100644 --- a/src/util/ForeignFifoBuffer.hxx +++ b/src/util/ForeignFifoBuffer.hxx @@ -222,11 +222,11 @@ public: * * @return the number of items moved */ - constexpr size_type MoveFrom(ForeignFifoBuffer &src) noexcept { - auto r = src.Read(); + template + constexpr size_type MoveFrom(std::span src) noexcept { auto w = Write(); - if (w.size() < r.size() && head > 0) { + if (src.size() > w.size() && head > 0) { /* if the source contains more data than we can append at the tail, try to make more room by shifting the head to 0 */ @@ -234,13 +234,18 @@ public: w = Write(); } - if (r.size() > w.size()) - r = r.first(w.size()); + if (src.size() > w.size()) + src = src.first(w.size()); - std::move(r.begin(), r.end(), w.begin()); - Append(r.size()); - src.Consume(r.size()); - return r.size(); + std::move(src.begin(), src.end(), w.begin()); + Append(src.size()); + return src.size(); + } + + constexpr size_type MoveFrom(ForeignFifoBuffer &src) noexcept { + auto n = MoveFrom(src.Read()); + src.Consume(n); + return n; } protected: