Michele Caini 6 лет назад
Родитель
Сommit
fc0432df8c
2 измененных файлов с 3 добавлено и 4 удалено
  1. 1 0
      TODO
  2. 2 4
      src/entt/entity/registry.hpp

+ 1 - 0
TODO

@@ -19,6 +19,7 @@
 * any-of rule for views/groups (eg entity has A and any of B/C/D)
   - get -> all, exclude -> none
 * deprecate sigh::publish, use operator()
+* remove args... from registry::assure and the others (index would be duplicated)
 
 * WIP: snapshot rework/deprecation
  - remove snapshot/loader from registry, make them external (faster) tools

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

@@ -199,10 +199,8 @@ class basic_registry {
     const pool_handler<Component> & assure(Args &&... args) const {
         static std::size_t index{pools.size()};
 
-        if(!(index < pools.size()) || pools[index].type_id != type_info<Component>::id()) {
-            index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&pdata) {
-                return pdata.type_id == type_info<Component>::id();
-            }) - pools.cbegin();
+        if(const auto length = pools.size(); !(index < length) || pools[index].type_id != type_info<Component>::id()) {
+            for(index = {}; index < length && pools[index].type_id != type_info<Component>::id(); ++index);
 
             if(index == pools.size()) {
                 auto &&pdata = pools.emplace_back();