Browse Source

registry:
* removed registry::reserve<Component> (use registry.storage<Component>.reserve(v) instead)
* removed registry::capacity<Component> (use registry.storage<Component>.capacity() instead)
* removed registry::shrink_to_fit<Component> (use registry.storage<Component>.shrink_to_fit() instead)

Michele Caini 4 years ago
parent
commit
f30ea02794
3 changed files with 4 additions and 55 deletions
  1. 2 42
      src/entt/entity/registry.hpp
  2. 0 11
      test/entt/entity/registry.cpp
  3. 2 2
      test/entt/entity/runtime_view.cpp

+ 2 - 42
src/entt/entity/registry.hpp

@@ -31,12 +31,6 @@ namespace entt {
 
 /**
  * @brief Fast and reliable entity-component system.
- *
- * The registry is the core class of the entity-component framework.<br/>
- * It stores entities and arranges pools of components on a per request basis.
- * By means of a registry, users can manage entities and components, then create
- * views or groups to iterate them.
- *
  * @tparam Entity A valid entity type (see entt_traits for more details).
  */
 template<typename Entity>
@@ -251,35 +245,11 @@ public:
     }
 
     /**
-     * @brief Increases the capacity of the registry or of the pools for the
-     * given components.
-     *
-     * If no components are specified, the capacity of the registry is
-     * increased, that is the number of entities it contains. Otherwise the
-     * capacity of the pools for the given components is increased.<br/>
-     * In both cases, if the new capacity is greater than the current capacity,
-     * new storage is allocated, otherwise the method does nothing.
-     *
-     * @tparam Component Types of components for which to reserve storage.
+     * @brief Increases the capacity (number of entities) of the registry.
      * @param cap Desired capacity.
      */
-    template<typename... Component>
     void reserve(const size_type cap) {
-        if constexpr(sizeof...(Component) == 0) {
-            entities.reserve(cap);
-        } else {
-            (assure<Component>().reserve(cap), ...);
-        }
-    }
-
-    /**
-     * @brief Returns the capacity of the pool for the given component.
-     * @tparam Component Type of component in which one is interested.
-     * @return Capacity of the pool of the given component.
-     */
-    template<typename Component>
-    [[nodiscard]] size_type capacity() const {
-        return assure<std::remove_const_t<Component>>().capacity();
+        entities.reserve(cap);
     }
 
     /**
@@ -291,16 +261,6 @@ public:
         return entities.capacity();
     }
 
-    /**
-     * @brief Requests the removal of unused capacity for the given components.
-     * @tparam Component Types of components for which to reclaim unused
-     * capacity.
-     */
-    template<typename... Component>
-    void shrink_to_fit() {
-        (assure<Component>().shrink_to_fit(), ...);
-    }
-
     /**
      * @brief Checks whether the registry or the pools of the given components
      * are empty.

+ 0 - 11
test/entt/entity/registry.cpp

@@ -162,13 +162,10 @@ TEST(Registry, Functionalities) {
 
     ASSERT_EQ(registry.size(), 0u);
     ASSERT_EQ(registry.alive(), 0u);
-    ASSERT_NO_FATAL_FAILURE((registry.reserve<int, char>(8)));
     ASSERT_NO_FATAL_FAILURE(registry.reserve(42));
     ASSERT_TRUE(registry.empty());
 
     ASSERT_EQ(registry.capacity(), 42u);
-    ASSERT_EQ(registry.capacity<int>(), ENTT_PACKED_PAGE);
-    ASSERT_EQ(registry.capacity<char>(), ENTT_PACKED_PAGE);
     ASSERT_EQ(registry.size<int>(), 0u);
     ASSERT_EQ(registry.size<const char>(), 0u);
     ASSERT_TRUE((registry.empty<int, const char>()));
@@ -307,14 +304,6 @@ TEST(Registry, Functionalities) {
     ASSERT_EQ(registry.size<const int>(), 0u);
     ASSERT_EQ(registry.size<char>(), 0u);
     ASSERT_TRUE(registry.empty<int>());
-
-    ASSERT_EQ(registry.capacity<int>(), ENTT_PACKED_PAGE);
-    ASSERT_EQ(registry.capacity<const char>(), ENTT_PACKED_PAGE);
-
-    registry.shrink_to_fit<int, char>();
-
-    ASSERT_EQ(registry.capacity<const int>(), 0u);
-    ASSERT_EQ(registry.capacity<char>(), 0u);
 }
 
 TEST(Registry, Move) {

+ 2 - 2
test/entt/entity/runtime_view.cpp

@@ -19,8 +19,8 @@ TEST(RuntimeView, Functionalities) {
     entt::registry registry;
 
     // forces the creation of the pools
-    registry.reserve<int>(0);
-    registry.reserve<char>(0);
+    static_cast<void>(registry.storage<int>());
+    static_cast<void>(registry.storage<char>());
 
     entt::id_type types[] = {entt::type_hash<int>::value(), entt::type_hash<char>::value()};
     auto view = registry.runtime_view(std::begin(types), std::end(types));