From f455846d18b4e8ba90adc5240758c829a83ffae5 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 6 Jul 2021 16:35:36 +0200 Subject: [PATCH] sparse_set/storage: avoid using temporary allocators --- src/entt/entity/sparse_set.hpp | 10 +++++++--- src/entt/entity/storage.hpp | 33 ++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index b0388334f..0ae231cce 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -305,13 +305,17 @@ public: */ explicit basic_sparse_set(deletion_policy pol, const allocator_type &allocator = {}) : reserved{allocator, 0u}, - sparse{alloc_ptr_traits::allocate(alloc_ptr{reserved.first()}, 0u)}, - packed{alloc_traits::allocate(reserved.first(), 0u)}, + sparse{}, + packed{}, bucket{0u}, count{0u}, free_list{tombstone}, mode{pol} - {} + { + alloc_ptr allocator_ptr{reserved.first()}; + sparse = alloc_ptr_traits::allocate(allocator_ptr, 0u); + packed = alloc_traits::allocate(reserved.first(), 0u); + } /** * @brief Constructs an empty container with the given allocator. diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index f08384307..600a80ed0 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -181,34 +181,34 @@ class basic_storage_impl: public basic_sparse_set