From 93bf0fc5478c69ef502d49bc4d1f1bd0e20f7a2b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 30 May 2022 12:55:23 +0200 Subject: [PATCH] util/ForeignFifoBuffer: use iterators --- src/util/ForeignFifoBuffer.hxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/ForeignFifoBuffer.hxx b/src/util/ForeignFifoBuffer.hxx index 8d515eb3e..e11db2010 100644 --- a/src/util/ForeignFifoBuffer.hxx +++ b/src/util/ForeignFifoBuffer.hxx @@ -234,12 +234,13 @@ public: w = Write(); } - const auto n = std::min(r.size(), w.size()); + if (r.size() > w.size()) + r = r.first(w.size()); - std::move(r.data(), r.data() + n, w.data()); - Append(n); - src.Consume(n); - return n; + std::move(r.begin(), r.end(), w.begin()); + Append(r.size()); + src.Consume(r.size()); + return r.size(); } protected: