util/{Static,Foreign}FifoBuffer: lazy shift

Reduce the number of unnecessary memmove() calls.
This commit is contained in:
Max Kellermann 2014-08-07 16:11:00 +02:00
parent ab9c527274
commit 67958f7fa7
2 changed files with 10 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);
}