mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd::buffer: Add window_buffer::rewind(n).
This commit is contained in:
parent
373a791158
commit
b528920420
1 changed files with 11 additions and 0 deletions
|
@ -36,6 +36,7 @@ struct ircd::buffer::window_buffer
|
|||
mutable_buffer completed();
|
||||
|
||||
const_buffer operator()(const closure &closure);
|
||||
const_buffer rewind(const size_t &n = 1);
|
||||
|
||||
window_buffer(const mutable_buffer &base);
|
||||
};
|
||||
|
@ -46,6 +47,16 @@ ircd::buffer::window_buffer::window_buffer(const mutable_buffer &base)
|
|||
,base{base}
|
||||
{}
|
||||
|
||||
inline ircd::buffer::const_buffer
|
||||
ircd::buffer::window_buffer::rewind(const size_t &n)
|
||||
{
|
||||
const size_t nmax{std::min(n, consumed())};
|
||||
static_cast<mutable_buffer &>(*this).begin() -= nmax;
|
||||
assert(base.begin() <= begin());
|
||||
assert(begin() <= base.end());
|
||||
return completed();
|
||||
}
|
||||
|
||||
inline ircd::buffer::const_buffer
|
||||
ircd::buffer::window_buffer::operator()(const closure &closure)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue