From 67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 7 Aug 2014 16:11:00 +0200 Subject: util/{Static,Foreign}FifoBuffer: lazy shift Reduce the number of unnecessary memmove() calls. --- src/util/ForeignFifoBuffer.hxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/util/ForeignFifoBuffer.hxx') diff --git a/src/util/ForeignFifoBuffer.hxx b/src/util/ForeignFifoBuffer.hxx index 0ebcd6069..b829fb030 100644 --- a/src/util/ForeignFifoBuffer.hxx +++ b/src/util/ForeignFifoBuffer.hxx @@ -147,7 +147,11 @@ public: * When you are finished, call append(). */ Range Write() { - Shift(); + if (IsEmpty()) + Clear(); + else if (tail == capacity) + Shift(); + return Range(data + tail, capacity - tail); } -- cgit v1.2.3