diff options
author | Max Kellermann <max@duempel.org> | 2014-08-07 16:11:00 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-07 16:11:00 +0200 |
commit | 67958f7fa7ae0d9b91fcd6025cda6c6abbecd6da (patch) | |
tree | fb8e181fc60bb4c9c25c0319709c149f88ccfd15 /src/util/StaticFifoBuffer.hxx | |
parent | ab9c5272741f5c348471cbeee5c9dbe7b562b9fd (diff) | |
download | mpd-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/StaticFifoBuffer.hxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/StaticFifoBuffer.hxx b/src/util/StaticFifoBuffer.hxx index 67645638e..c1b64bb1e 100644 --- a/src/util/StaticFifoBuffer.hxx +++ b/src/util/StaticFifoBuffer.hxx @@ -92,7 +92,11 @@ public: * When you are finished, call append(). */ Range Write() { - Shift(); + if (IsEmpty()) + Clear(); + else if (tail == size) + Shift(); + return Range(data + tail, size - tail); } |