diff --git a/include/ircd/buffer/buffer_base.h b/include/ircd/buffer/buffer_base.h index 150a077e1..416b12db1 100644 --- a/include/ircd/buffer/buffer_base.h +++ b/include/ircd/buffer/buffer_base.h @@ -36,6 +36,7 @@ struct ircd::buffer::buffer explicit operator std::string() const; operator string_view() const; + buffer(const buffer &start, const size_t &size); buffer(const it &start, const it &stop); buffer(const it &start, const size_t &size); buffer(); @@ -61,6 +62,16 @@ ircd::buffer::buffer::buffer(const it &start, :std::pair{start, stop} {} +template +inline __attribute__((always_inline)) +ircd::buffer::buffer::buffer(const buffer &start, + const size_t &size) +:buffer +{ + data(start), std::min(ircd::buffer::size(start), size) +} +{} + template inline __attribute__((always_inline, flatten)) ircd::buffer::buffer::operator string_view() diff --git a/include/ircd/buffer/const_buffer.h b/include/ircd/buffer/const_buffer.h index e9e14b811..5dffe1543 100644 --- a/include/ircd/buffer/const_buffer.h +++ b/include/ircd/buffer/const_buffer.h @@ -24,6 +24,7 @@ struct ircd::buffer::const_buffer template const_buffer(const char (&buf)[SIZE]); template const_buffer(const std::array &buf); const_buffer(const buffer &b); + const_buffer(const buffer &b, const size_t &); const_buffer(const buffer &b); const_buffer(const mutable_buffer &b); const_buffer(const string_view &s); @@ -42,6 +43,13 @@ ircd::buffer::const_buffer::const_buffer(const buffer &b) :buffer{data(b), size(b)} {} +inline +__attribute__((always_inline)) +ircd::buffer::const_buffer::const_buffer(const buffer &b, + const size_t &max) +:buffer{{data(b), size(b)}, max} +{} + inline __attribute__((always_inline)) ircd::buffer::const_buffer::const_buffer(const mutable_buffer &b)