static_buffer::consume improvement

This commit is contained in:
Vinnie Falco
2017-07-17 08:12:30 -07:00
parent 834682e650
commit ed7c095df9
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,7 @@
Version 84:
* Tidy up buffer_front
* static_buffer::consume improvement
--------------------------------------------------------------------------------

View File

@ -260,9 +260,19 @@ void
static_buffer_base::
consume(std::size_t size)
{
size = (std::min)(size, in_size_);
in_off_ = (in_off_ + size) % capacity_;
in_size_ -= size;
if(size < in_size_)
{
in_off_ = (in_off_ + size) % capacity_;
in_size_ -= size;
}
else
{
// rewind the offset, so the next call to prepare
// can have a longer continguous segment. this helps
// algorithms optimized for larger buffesr.
in_off_ = 0;
in_size_ = 0;
}
}
inline