aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/ForeignFifoBuffer.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-07 16:11:00 +0200
committerMax Kellermann <max@duempel.org>2014-08-07 16:11:00 +0200
commit67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da (patch)
treefb8e181fc60bb4c9c25c0319709c149f88ccfd15 /src/util/ForeignFifoBuffer.hxx
parentab9c5272741f5c348471cbeee5c9dbe7b562b9fd (diff)
downloadmpd-67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da.tar.gz
mpd-67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da.tar.xz
mpd-67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da.zip
util/{Static,Foreign}FifoBuffer: lazy shift
Reduce the number of unnecessary memmove() calls.
Diffstat (limited to '')
-rw-r--r--src/util/ForeignFifoBuffer.hxx6
1 files changed, 5 insertions, 1 deletions
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);
}