From 3299fa1e40a10e5fca76ab541ec5038a52a5bc0f Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 6 Jun 2024 11:00:10 +0200 Subject: [PATCH] sparse_set: review/cleanup constructors --- src/entt/entity/sparse_set.hpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 98a03052f..a9a64a95f 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -391,15 +391,15 @@ public: using const_reverse_iterator = std::reverse_iterator; /*! @brief Default constructor. */ - basic_sparse_set() - : basic_sparse_set{type_id()} {} + basic_sparse_set() = default; /** * @brief Constructs an empty container with a given allocator. * @param allocator The allocator to use. */ explicit basic_sparse_set(const allocator_type &allocator) - : basic_sparse_set{type_id(), deletion_policy::swap_and_pop, allocator} {} + : sparse{allocator}, + packed{allocator} {} /** * @brief Constructs an empty container with the given policy and allocator. @@ -407,7 +407,10 @@ public: * @param allocator The allocator to use (possibly default-constructed). */ explicit basic_sparse_set(deletion_policy pol, const allocator_type &allocator = {}) - : basic_sparse_set{type_id(), pol, allocator} {} + : sparse{allocator}, + packed{allocator}, + mode{pol}, + head{policy_to_head()} {} /** * @brief Constructs an empty container with the given value type, policy @@ -1057,11 +1060,11 @@ public: virtual void bind(any) noexcept {} private: - sparse_container_type sparse; - packed_container_type packed; - const type_info *info; - deletion_policy mode; - size_type head; + sparse_container_type sparse{}; + packed_container_type packed{}; + const type_info *info{&type_id()}; + deletion_policy mode{deletion_policy::swap_and_pop}; + size_type head{max_size}; }; } // namespace entt