Browse Source

registry: reduce instantiations

Michele Caini 6 years ago
parent
commit
38a80a95f2
1 changed files with 7 additions and 8 deletions
  1. 7 8
      src/entt/entity/registry.hpp

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

@@ -192,14 +192,13 @@ class basic_registry {
             for(index = {}; index < length && pools[index].type_id != type_info<Component>::id(); ++index);
 
             if(index == pools.size()) {
-                auto &&pdata = pools.emplace_back();
-
-                pdata.type_id = type_info<Component>::id();
-                pdata.pool.reset(new pool_handler<Component>());
-
-                pdata.remove = [](sparse_set<entity_type> &cpool, basic_registry &owner, const entity_type entt) {
-                    static_cast<pool_handler<Component> &>(cpool).remove(owner, entt);
-                };
+                pools.push_back(pool_data{
+                    type_info<Component>::id(),
+                    std::unique_ptr<sparse_set<entity_type>>{new pool_handler<Component>()},
+                    [](sparse_set<entity_type> &cpool, basic_registry &owner, const entity_type entt) {
+                        static_cast<pool_handler<Component> &>(cpool).remove(owner, entt);
+                    }
+                });
             }
         }