registry: ctor that reserves enough memory for count pools
This commit is contained in:
@@ -333,7 +333,25 @@ public:
|
||||
using context = internal::registry_context;
|
||||
|
||||
/*! @brief Default constructor. */
|
||||
basic_registry() = default;
|
||||
basic_registry()
|
||||
: pools{},
|
||||
groups{},
|
||||
entities{},
|
||||
free_list{tombstone},
|
||||
vars{} {}
|
||||
|
||||
/**
|
||||
* @brief Allocates enough memory upon construction to store `count` pools.
|
||||
* @param count The number of pools to allocate memory for.
|
||||
*/
|
||||
basic_registry(const size_type count)
|
||||
: pools{},
|
||||
groups{},
|
||||
entities{},
|
||||
free_list{tombstone},
|
||||
vars{} {
|
||||
pools.reserve(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Move constructor.
|
||||
@@ -1465,10 +1483,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
dense_map<id_type, std::unique_ptr<base_type>, identity> pools{};
|
||||
std::vector<group_data> groups{};
|
||||
std::vector<entity_type> entities{};
|
||||
entity_type free_list{tombstone};
|
||||
dense_map<id_type, std::unique_ptr<base_type>, identity> pools;
|
||||
std::vector<group_data> groups;
|
||||
std::vector<entity_type> entities;
|
||||
entity_type free_list;
|
||||
context vars;
|
||||
};
|
||||
|
||||
|
||||
@@ -337,6 +337,18 @@ TEST(Registry, Functionalities) {
|
||||
ASSERT_TRUE(registry.storage<int>().empty());
|
||||
}
|
||||
|
||||
TEST(Registry, Constructors) {
|
||||
entt::registry registry;
|
||||
entt::registry other{42};
|
||||
const entt::entity entity = entt::tombstone;
|
||||
|
||||
ASSERT_TRUE(registry.empty());
|
||||
ASSERT_TRUE(other.empty());
|
||||
|
||||
ASSERT_EQ(registry.released(), entity);
|
||||
ASSERT_EQ(other.released(), entity);
|
||||
}
|
||||
|
||||
TEST(Registry, Move) {
|
||||
entt::registry registry;
|
||||
const auto entity = registry.create();
|
||||
|
||||
Reference in New Issue
Block a user