0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

ircd::buffer: Hoist null_buffer to inline variable; move buffers typedefs.

This commit is contained in:
Jason Volk 2022-07-01 09:48:48 -07:00
parent d68f261036
commit 81b6c7b003
3 changed files with 23 additions and 18 deletions

View file

@ -46,17 +46,14 @@ namespace ircd::buffer
template<size_t SIZE> using fixed_const_buffer = fixed_buffer<const_buffer, SIZE>;
template<size_t SIZE> using fixed_mutable_buffer = fixed_buffer<mutable_buffer, SIZE>;
template<template<class> class I> using const_buffers = I<const_buffer>;
template<template<class> class I> using mutable_buffers = I<mutable_buffer>;
using unique_const_buffer = unique_buffer<const_buffer>;
using unique_mutable_buffer = unique_buffer<mutable_buffer>;
using shared_const_buffer = shared_buffer<const_buffer>;
using shared_mutable_buffer = shared_buffer<mutable_buffer>;
// Preconstructed null buffers
// Convenience null buffer
extern const mutable_buffer null_buffer;
extern const ilist<mutable_buffer> null_buffers;
// Single buffer iteration of contents
template<class it> const it &begin(const buffer<it> &buffer);
@ -121,9 +118,11 @@ namespace ircd
using buffer::unique_mutable_buffer;
using buffer::shared_const_buffer;
using buffer::shared_mutable_buffer;
using buffer::null_buffer;
using buffer::const_buffers;
using buffer::mutable_buffers;
using buffers::const_buffers;
using buffers::mutable_buffers;
using buffers::null_buffers;
using buffer::size;
using buffer::data;
@ -351,3 +350,15 @@ ircd::buffer::begin(const buffer<it> &buffer)
{
return get<0>(buffer);
}
inline decltype(ircd::buffer::null_buffer)
ircd::buffer::null_buffer
{
nullptr, nullptr
};
inline decltype(ircd::buffers::null_buffers)
ircd::buffers::null_buffers
{
{ null_buffer }
};

View file

@ -13,6 +13,12 @@
namespace ircd::buffer::buffers
{
template<template<class> class I> using const_buffers = I<const_buffer>;
template<template<class> class I> using mutable_buffers = I<mutable_buffer>;
// Convenience null buffers
extern const ilist<mutable_buffer> null_buffers;
// Iterable of buffers tools
template<template<class> class I, class T> size_t size(const I<T> &buffers);
template<template<class> class I, class T> size_t copy(const mutable_buffer &, const I<T> &buffer);

View file

@ -3204,18 +3204,6 @@ ircd::net::string(const mutable_buffer &out,
// buffer.h - provide definition for the null buffers and asio conversion
//
const ircd::buffer::mutable_buffer
ircd::buffer::null_buffer
{
nullptr, nullptr
};
const ircd::ilist<ircd::buffer::mutable_buffer>
ircd::buffer::null_buffers
{{
null_buffer
}};
[[gnu::visibility("protected")]]
ircd::buffer::mutable_buffer::operator
boost::asio::mutable_buffer()