From 8d0af9a0e352dd4ed143352db74d458c6a297c41 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 12 Dec 2025 14:40:16 -0500 Subject: [PATCH] xo-alloc2: make AAllocator.name() -> string_view --- xo-alloc2/include/xo/alloc2/AAllocator.hpp | 2 +- xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp | 2 +- xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp | 2 +- xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp | 2 +- xo-alloc2/include/xo/alloc2/RAllocator.hpp | 2 +- xo-alloc2/src/alloc2/IAllocator_DArena.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xo-alloc2/include/xo/alloc2/AAllocator.hpp b/xo-alloc2/include/xo/alloc2/AAllocator.hpp index d2903d9d..38c545f8 100644 --- a/xo-alloc2/include/xo/alloc2/AAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/AAllocator.hpp @@ -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. diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp index d0caa3a9..c4cf1b99 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_Any.hpp @@ -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(); } diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp index ad573879..15a9c9ff 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_DArena.hpp @@ -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; diff --git a/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp b/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp index 54a69153..be5f2157 100644 --- a/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/IAllocator_Xfer.hpp @@ -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)); } diff --git a/xo-alloc2/include/xo/alloc2/RAllocator.hpp b/xo-alloc2/include/xo/alloc2/RAllocator.hpp index e95c7bcd..32e58e66 100644 --- a/xo-alloc2/include/xo/alloc2/RAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/RAllocator.hpp @@ -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()); } diff --git a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp index dbf708b0..cd3ec546 100644 --- a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp +++ b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp @@ -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_; }