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

+ 0 - 2
TODO

@@ -8,8 +8,6 @@
 * custom (decoupled) pools ==> N-buffering, shared components, multi-model, hibitsets, and so on
 * add examples (and credits) from @alanjfs :)
 * static reflection, hint: template<> meta_type_t<Type>: meta_descriptor<name, func..., props..., etc...> (see #342)
-* add meta support to registry (eg entity for each component and opaque get)
-* allow for custom stamp functions
 * observer: user defined filters (eg .replace<T, &function> or .group<T, U, &func>)
 * use underlying_type as entity type within pools and registry? it would make different registries work together flawlessy
 * can we write a bool conv func for entt::entity that silently compares it to null?

+ 4 - 7
src/entt/signal/dispatcher.hpp

@@ -6,7 +6,6 @@
 #include <memory>
 #include <cstddef>
 #include <utility>
-#include <algorithm>
 #include <type_traits>
 #include "../config/config.h"
 #include "../core/type_info.hpp"
@@ -84,10 +83,8 @@ class dispatcher {
         static_assert(std::is_same_v<Event, std::decay_t<Event>>);
         static std::size_t index{pools.size()};
 
-        if(!(index < pools.size()) || pools[index]->type_id() != type_info<Event>::id()) {
-            index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&cpool) {
-                return cpool->type_id() == type_info<Event>::id();
-            }) - pools.cbegin();
+        if(const auto length = pools.size(); !(index < length) || pools[index]->type_id() != type_info<Event>::id()) {
+            for(index = {}; index < length && pools[index]->type_id() != type_info<Event>::id(); ++index);
 
             if(index == pools.size()) {
                 pools.push_back(std::make_unique<pool_handler<Event>>());
@@ -189,9 +186,9 @@ public:
     template<typename... Event>
     void clear() {
         if constexpr(sizeof...(Event) == 0) {
-            std::for_each(pools.begin(), pools.end(), [](auto &&cpool) {
+            for(auto &&cpool: pools) {
                 cpool->clear();
-            });
+            }
         } else {
             (assure<Event>().clear(), ...);
         }

+ 2 - 4
src/entt/signal/emitter.hpp

@@ -123,10 +123,8 @@ class emitter {
         static_assert(std::is_same_v<Event, std::decay_t<Event>>);
         static std::size_t index{pools.size()};
 
-        if(!(index < pools.size()) || pools[index]->type_id() != type_info<Event>::id()) {
-            index = std::find_if(pools.cbegin(), pools.cend(), [](auto &&cpool) {
-                return cpool->type_id() == type_info<Event>::id();
-            }) - pools.cbegin();
+        if(const auto length = pools.size(); !(index < length) || pools[index]->type_id() != type_info<Event>::id()) {
+            for(index = {}; index < length && pools[index]->type_id() != type_info<Event>::id(); ++index);
 
             if(index == pools.size()) {
                 pools.push_back(std::make_unique<pool_handler<Event>>());