refactor: rename shallow_copy -> shallow_move + streamline

Use RCollector.std_copy_for where appropriate
This commit is contained in:
Roland Conybeare 2026-04-04 16:33:35 -04:00
commit d0e6ab5b44
8 changed files with 19 additions and 12 deletions

View file

@ -245,7 +245,7 @@ namespace xo {
size_type shallow_size() const noexcept;
/** clone string, using memory from allocator @p mm **/
DString * shallow_move(obj<AAllocator> mm) const noexcept;
DString * shallow_move(obj<ACollector> gc) noexcept;
size_type forward_children(obj<ACollector> gc) noexcept;
/** fixup child pointers (trivial for DString, no children)

View file

@ -91,7 +91,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
/** clone unique string, using memory from allocator @p mm. **/
DUniqueString * shallow_move(obj<AAllocator> mm) const noexcept;
DUniqueString * shallow_move(obj<ACollector> gc) noexcept;
/** fixup child pointers (trivial for DUniqueString, no gc-owned children **/
std::size_t forward_children(obj<ACollector> gc) noexcept;

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DString & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DString & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DString & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DUniqueString & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DUniqueString & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DUniqueString & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -156,9 +156,12 @@ namespace xo {
}
DString *
DString::shallow_move(obj<AAllocator> mm) const noexcept
DString::shallow_move(obj<ACollector> gc) noexcept
{
DString * copy = (DString *)mm.alloc_copy((std::byte *)this);
// note: not using gc.std_copy_for() here
// b/c DString flexible array means not move-constructible
DString * copy = (DString *)gc.alloc_copy_for(this);
if (copy) {
copy->capacity_ = capacity_;

View file

@ -88,12 +88,16 @@ namespace xo {
}
DUniqueString *
DUniqueString::shallow_move(obj<AAllocator> mm) const noexcept
DUniqueString::shallow_move(obj<ACollector> gc) noexcept
{
// well-posed, but not expected to be used.
//
// Not using gc.std_copy_for() here because compiler doesn't know
// actual alloc size of a DUniqueString instance
assert(false);
DUniqueString * copy = (DUniqueString *)mm.alloc_copy((std::byte *)this);
DUniqueString * copy = (DUniqueString *)gc.alloc_copy((std::byte *)this);
if (copy) {
// Copy assignment not implemented in general

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DString::shallow_move(DString & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DString::shallow_move(DString & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DString::forward_children(DString & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DUniqueString::shallow_move(DUniqueString & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DUniqueString::shallow_move(DUniqueString & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DUniqueString::forward_children(DUniqueString & self, obj<ACollector> gc) noexcept -> size_type