From 6d69512c6ff58ee8a7c1266257db5bf94cc91886 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Tue, 17 Dec 2024 23:30:44 +0100 Subject: Refactor a bunch of memory utilities --- asl/buffer.hpp | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'asl/buffer.hpp') diff --git a/asl/buffer.hpp b/asl/buffer.hpp index 04444f0..8ee2869 100644 --- a/asl/buffer.hpp +++ b/asl/buffer.hpp @@ -132,30 +132,7 @@ public: T* new_data = reinterpret_cast(m_allocator.alloc(new_layout)); - // @Todo Move this logic somewhere else. Make move/destruct/etc. abstractions. - - if constexpr (trivially_copyable) - { - auto init_layout = layout::array(current_size); - memcpy(new_data, old_data, init_layout.size); - } - else - { - static_assert(move_constructible); - for (isize_t i = 0; i < current_size; ++i) - { - // NOLINTNEXTLINE(*-pointer-arithmetic) - new(new_data + i) T(ASL_MOVE(old_data[i])); - } - } - - if constexpr (!trivially_destructible) - { - for (isize_t i = 0; i < current_size; ++i) - { - (old_data + i)->~T(); - } - } + relocate_uninit_n(new_data, old_data, current_size); if (currently_on_heap) { -- cgit