diff --git a/CHANGELOG.md b/CHANGELOG.md index 68127431..7743365d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 84: * Tidy up buffer_front +* static_buffer::consume improvement -------------------------------------------------------------------------------- diff --git a/include/beast/core/impl/static_buffer.ipp b/include/beast/core/impl/static_buffer.ipp index c10e98aa..da1546dd 100644 --- a/include/beast/core/impl/static_buffer.ipp +++ b/include/beast/core/impl/static_buffer.ipp @@ -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