diff --git a/include/ircd/buffer/buffer.h b/include/ircd/buffer/buffer.h index 023a16f5b..f312625f7 100644 --- a/include/ircd/buffer/buffer.h +++ b/include/ircd/buffer/buffer.h @@ -217,6 +217,7 @@ ircd::buffer::operator<<(std::ostream &s, const buffer &buffer) // to ensure cross-platform guarantees the zero'ing doesn't get optimized away. #ifndef HAVE_SODIUM_H inline size_t +__attribute__((always_inline)) ircd::buffer::zero(const mutable_buffer &buf) { std::memset(data(buf), 0x0, size(buf)); @@ -225,12 +226,14 @@ ircd::buffer::zero(const mutable_buffer &buf) #endif inline void +__attribute__((always_inline)) ircd::buffer::reverse(const mutable_buffer &buf) { std::reverse(data(buf), data(buf) + size(buf)); } inline size_t +__attribute__((always_inline)) ircd::buffer::reverse(const mutable_buffer &dst, const const_buffer &src) { @@ -266,6 +269,7 @@ ircd::buffer::copy(const mutable_buffer &dst, } inline size_t +__attribute__((always_inline)) ircd::buffer::move(const mutable_buffer &dst, const const_buffer &src) { @@ -276,6 +280,7 @@ ircd::buffer::move(const mutable_buffer &dst, } inline size_t +__attribute__((always_inline)) ircd::buffer::copy(const mutable_buffer &dst, const const_buffer &src) { @@ -286,8 +291,8 @@ ircd::buffer::copy(const mutable_buffer &dst, } template -it -__attribute__((stack_protect)) +inline it +__attribute__((always_inline)) ircd::buffer::move(it &dest, const it &stop, const const_buffer &src) @@ -307,8 +312,8 @@ ircd::buffer::move(it &dest, } template -it -__attribute__((stack_protect)) +inline it +__attribute__((always_inline)) ircd::buffer::copy(it &dest, const it &stop, const const_buffer &src) @@ -328,7 +333,8 @@ ircd::buffer::copy(it &dest, } template -ircd::buffer::buffer +inline ircd::buffer::buffer +__attribute__((always_inline)) ircd::buffer::operator+(const buffer &buffer, const size_t &bytes) { @@ -344,7 +350,8 @@ ircd::buffer::operator+(const buffer &buffer, } template -size_t +inline size_t +__attribute__((always_inline)) ircd::buffer::consume(buffer &buffer, const size_t &bytes) { @@ -366,14 +373,16 @@ ircd::buffer::aligned(const buffer &buffer, } template -const it & +inline const it & +__attribute__((always_inline)) ircd::buffer::data(const buffer &buffer) { return get<0>(buffer); } template -size_t +inline size_t +__attribute__((always_inline)) ircd::buffer::size(const buffer &buffer) { assert(get<0>(buffer) <= get<1>(buffer)); diff --git a/include/ircd/buffer/buffer_base.h b/include/ircd/buffer/buffer_base.h index 2bb8f1e64..2eb326eb6 100644 --- a/include/ircd/buffer/buffer_base.h +++ b/include/ircd/buffer/buffer_base.h @@ -15,7 +15,7 @@ /// template struct ircd::buffer::buffer -:std::tuple +:std::pair { using iterator = it; using value_type = typename std::remove_pointer::type; @@ -42,23 +42,27 @@ struct ircd::buffer::buffer }; template +inline __attribute__((always_inline)) ircd::buffer::buffer::buffer() :buffer{nullptr, nullptr} {} template +inline __attribute__((always_inline)) ircd::buffer::buffer::buffer(const it &start, const size_t &size) :buffer{start, start + size} {} template +inline __attribute__((always_inline, flatten)) ircd::buffer::buffer::buffer(const it &start, const it &stop) -:std::tuple{start, stop} +:std::pair{start, stop} {} template +inline __attribute__((always_inline, flatten)) ircd::buffer::buffer::operator string_view() const { diff --git a/include/ircd/buffer/const_buffer.h b/include/ircd/buffer/const_buffer.h index 5acec1f55..cc83ffb3d 100644 --- a/include/ircd/buffer/const_buffer.h +++ b/include/ircd/buffer/const_buffer.h @@ -31,31 +31,37 @@ struct ircd::buffer::const_buffer }; inline +__attribute__((always_inline)) ircd::buffer::const_buffer::const_buffer(const buffer &b) :buffer{b} {} inline +__attribute__((always_inline)) 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 mutable_buffer &b) :buffer{data(b), size(b)} {} inline +__attribute__((always_inline)) ircd::buffer::const_buffer::const_buffer(const string_view &s) :buffer{data(s), size(s)} {} template +inline __attribute__((always_inline)) ircd::buffer::const_buffer::const_buffer(const char (&buf)[SIZE]) :buffer{buf, SIZE} {} template +inline __attribute__((always_inline)) ircd::buffer::const_buffer::const_buffer(const std::array &buf) :buffer{reinterpret_cast(buf.data()), SIZE} {} diff --git a/include/ircd/buffer/mutable_buffer.h b/include/ircd/buffer/mutable_buffer.h index 226dd894e..aaaca5d1e 100644 --- a/include/ircd/buffer/mutable_buffer.h +++ b/include/ircd/buffer/mutable_buffer.h @@ -36,6 +36,7 @@ struct ircd::buffer::mutable_buffer }; inline +__attribute__((always_inline)) ircd::buffer::mutable_buffer::mutable_buffer(const buffer &b) :buffer{b} {} @@ -43,22 +44,26 @@ ircd::buffer::mutable_buffer::mutable_buffer(const buffer &b) /// lvalue string reference offered to write through to a std::string as /// the buffer. should be hard to bind by accident... inline +__attribute__((always_inline)) ircd::buffer::mutable_buffer::mutable_buffer(std::string &buf) :mutable_buffer{const_cast(buf.data()), buf.size()} {} inline +__attribute__((always_inline)) ircd::buffer::mutable_buffer::mutable_buffer(const std::function &closure) { closure(*this); } template +inline __attribute__((always_inline, gnu_inline)) ircd::buffer::mutable_buffer::mutable_buffer(char (&buf)[SIZE]) :buffer{buf, SIZE} {} template +inline __attribute__((always_inline)) ircd::buffer::mutable_buffer::mutable_buffer(std::array &buf) :buffer{buf.data(), SIZE} {} diff --git a/include/ircd/string_view.h b/include/ircd/string_view.h index 7ad5688fb..46283ea3d 100644 --- a/include/ircd/string_view.h +++ b/include/ircd/string_view.h @@ -156,16 +156,18 @@ struct ircd::string_view {} // (non-standard) our array based constructor - template - constexpr string_view(const std::array &array) + template constexpr + __attribute__((always_inline)) + string_view(const std::array &array) :string_view { array.data(), std::find(array.begin(), array.end(), '\0') }{} // (non-standard) our buffer based constructor - template - constexpr string_view(const char (&buf)[SIZE]) + template constexpr + __attribute__((always_inline)) + string_view(const char (&buf)[SIZE]) :string_view { buf, std::find(buf, buf + SIZE, '\0')