Browse Source

sparse_set/storage: no virtual swap (the silliest thing I've ever done)

Michele Caini 4 years ago
parent
commit
ad3fbe2052
2 changed files with 11 additions and 15 deletions
  1. 0 4
      src/entt/entity/sparse_set.hpp
  2. 11 11
      src/entt/entity/storage.hpp

+ 0 - 4
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);

+ 11 - 11
src/entt/entity/storage.hpp

@@ -283,17 +283,6 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
     }
 
 protected:
-    /**
-     * @brief Exchanges the contents with those of a given storage.
-     * @param base Reference to base storage to exchange the content with.
-     */
-    void swap_contents(underlying_type &base) override {
-        using std::swap;
-        auto &other = static_cast<basic_storage &>(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.