mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::buffer: Minor cleanup; operator stack reuse.
This commit is contained in:
parent
19b9113222
commit
55c3c54aef
1 changed files with 13 additions and 4 deletions
|
@ -272,7 +272,11 @@ __attribute__((always_inline))
|
||||||
ircd::buffer::reverse(const mutable_buffer &dst,
|
ircd::buffer::reverse(const mutable_buffer &dst,
|
||||||
const const_buffer &src)
|
const const_buffer &src)
|
||||||
{
|
{
|
||||||
const size_t ret{std::min(size(dst), size(src))};
|
const size_t ret
|
||||||
|
{
|
||||||
|
std::min(size(dst), size(src))
|
||||||
|
};
|
||||||
|
|
||||||
std::reverse_copy(data(src), data(src) + ret, data(dst));
|
std::reverse_copy(data(src), data(src) + ret, data(dst));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +287,11 @@ __attribute__((always_inline))
|
||||||
ircd::buffer::operator+=(buffer<it> &buffer,
|
ircd::buffer::operator+=(buffer<it> &buffer,
|
||||||
const size_t &bytes)
|
const size_t &bytes)
|
||||||
{
|
{
|
||||||
const size_t &advance(std::min(bytes, size(buffer)));
|
const size_t &advance
|
||||||
|
{
|
||||||
|
std::min(bytes, size(buffer))
|
||||||
|
};
|
||||||
|
|
||||||
consume(buffer, advance);
|
consume(buffer, advance);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -329,8 +337,9 @@ __attribute__((always_inline))
|
||||||
ircd::buffer::operator+(const buffer<it> &buffer,
|
ircd::buffer::operator+(const buffer<it> &buffer,
|
||||||
const size_t &bytes)
|
const size_t &bytes)
|
||||||
{
|
{
|
||||||
const size_t advance{std::min(bytes, size(buffer))};
|
auto ret(buffer);
|
||||||
return { begin(buffer) + advance, size(buffer) - advance };
|
ret += bytes;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class it>
|
template<class it>
|
||||||
|
|
Loading…
Reference in a new issue