Просмотр исходного кода

registry: added ::reserve_pools

Michele Caini 5 лет назад
Родитель
Сommit
a7a2c96382
2 измененных файлов с 9 добавлено и 0 удалено
  1. 8 0
      src/entt/entity/registry.hpp
  2. 1 0
      test/entt/entity/registry.cpp

+ 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.
      * @brief Returns the capacity of the pool for the given component.
      * @tparam Component Type of component in which one is interested.
      * @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.size(), 0u);
     ASSERT_EQ(registry.alive(), 0u);
     ASSERT_EQ(registry.alive(), 0u);
     ASSERT_NO_THROW((registry.reserve<int, char>(8)));
     ASSERT_NO_THROW((registry.reserve<int, char>(8)));
+    ASSERT_NO_THROW(registry.reserve_pools(16));
     ASSERT_NO_THROW(registry.reserve(42));
     ASSERT_NO_THROW(registry.reserve(42));
     ASSERT_TRUE(registry.empty());
     ASSERT_TRUE(registry.empty());