xo-alloc2: make AAllocator.name() -> string_view

This commit is contained in:
Roland Conybeare 2025-12-12 14:40:16 -05:00
commit 8d0af9a0e3
6 changed files with 6 additions and 6 deletions

View file

@ -89,7 +89,7 @@ namespace xo {
/** optional name for allocator @p d
* Labeling, for diagnostics.
**/
virtual const std::string & name(Copaque d) const noexcept = 0;
virtual std::string_view name(Copaque d) const noexcept = 0;
/** reserved size in bytes for allocator @p d.
* Includes committed + uncommitted memory.
* Cannot be increased.

View file

@ -31,7 +31,7 @@ namespace xo {
// from AAllocator
int32_t _typeseq() const noexcept override { return s_typeseq; }
[[noreturn]] const std::string & name(Copaque) const noexcept override { _fatal(); }
[[noreturn]] std::string_view name(Copaque) const noexcept override { _fatal(); }
[[noreturn]] size_type reserved(Copaque) const noexcept override { _fatal(); }
[[noreturn]] size_type size(Copaque) const noexcept override { _fatal(); }
[[noreturn]] size_type committed(Copaque) const noexcept override { _fatal(); }

View file

@ -30,7 +30,7 @@ namespace xo {
struct IAllocator_DArena {
using size_type = std::size_t;
static const std::string & name(const DArena &) noexcept;
static std::string_view name(const DArena &) noexcept;
static size_type reserved(const DArena &) noexcept;
static size_type size(const DArena &) noexcept;
static size_type committed(const DArena &) noexcept;

View file

@ -28,7 +28,7 @@ namespace xo {
// const methods
int32_t _typeseq() const noexcept override { return s_typeseq; }
const std::string & name(Copaque d) const noexcept override { return I::name(_dcast(d)); }
std::string_view name(Copaque d) const noexcept override { return I::name(_dcast(d)); }
size_type reserved(Copaque d) const noexcept override { return I::reserved(_dcast(d)); }
size_type size(Copaque d) const noexcept override { return I::size(_dcast(d)); }
size_type committed(Copaque d) const noexcept override { return I::committed(_dcast(d)); }

View file

@ -23,7 +23,7 @@ namespace xo {
RAllocator(Object::DataPtr data) : Object{std::move(data)} {}
int32_t _typeseq() const { return O::iface()->_typeseq(); }
const std::string & name() const { return O::iface()->name(O::data()); }
std::string_view name() const { return O::iface()->name(O::data()); }
size_type reserved() const { return O::iface()->reserved(O::data()); }
size_type size() const { return O::iface()->size(O::data()); }
size_type committed() const { return O::iface()->committed(O::data()); }

View file

@ -16,7 +16,7 @@ namespace xo {
namespace mm {
const std::string &
std::string_view
IAllocator_DArena::name(const DArena & s) noexcept {
return s.config_.name_;
}