From ad3fbe20525e5bb48a94c8a2e8fd2166154ae17b Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 19 Nov 2021 11:22:27 +0100 Subject: [PATCH] sparse_set/storage: no virtual swap (the silliest thing I've ever done) --- src/entt/entity/sparse_set.hpp | 4 ---- src/entt/entity/storage.hpp | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 4f9af8b64..dd111ca53 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -195,9 +195,6 @@ class basic_sparse_set { } protected: - /*! @brief Exchanges the contents with those of a given sparse set. */ - virtual void swap_contents(basic_sparse_set &) {} - /*! @brief Swaps two entities in a sparse set. */ virtual void swap_at(const std::size_t, const std::size_t) {} @@ -355,7 +352,6 @@ public: */ void swap(basic_sparse_set &other) { using std::swap; - swap_contents(other); swap(sparse, other.sparse); swap(packed, other.packed); swap(free_list, other.free_list); diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index 3a12112a9..0210dc487 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -283,17 +283,6 @@ class basic_storage: public basic_sparse_set(base); - propagate_on_container_swap(packed.second(), other.packed.second()); - swap(packed.first(), other.packed.first()); - } - /** * @brief Swaps two elements in a storage. * @param lhs A valid position of an element within a storage. @@ -451,6 +440,17 @@ public: return *this; } + /** + * @brief Exchanges the contents with those of a given storage. + * @param other Storage to exchange the content with. + */ + void swap(basic_storage &other) { + using std::swap; + underlying_type::swap(other); + propagate_on_container_swap(packed.second(), other.packed.second()); + swap(packed.first(), other.packed.first()); + } + /** * @brief Returns the associated allocator. * @return The associated allocator.