1
0
Эх сурвалжийг харах

registry: added ::reserve_pools

Michele Caini 5 жил өмнө
parent
commit
a7a2c96382

+ 8 - 0
src/entt/entity/registry.hpp

@@ -251,6 +251,14 @@ public:
         }
     }
 
+    /**
+     * @brief Reserves enough space to store `count` pools.
+     * @param count Number of pools to reserve space for.
+     */
+    void reserve_pools(const size_t count) {
+        pools.reserve(count);
+    }
+
     /**
      * @brief Returns the capacity of the pool for the given component.
      * @tparam Component Type of component in which one is interested.

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

@@ -103,6 +103,7 @@ TEST(Registry, Functionalities) {
     ASSERT_EQ(registry.size(), 0u);
     ASSERT_EQ(registry.alive(), 0u);
     ASSERT_NO_THROW((registry.reserve<int, char>(8)));
+    ASSERT_NO_THROW(registry.reserve_pools(16));
     ASSERT_NO_THROW(registry.reserve(42));
     ASSERT_TRUE(registry.empty());