Răsfoiți Sursa

view: faster contains

Michele Caini 6 ani în urmă
părinte
comite
cd4bcce70f
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      src/entt/entity/view.hpp

+ 3 - 2
src/entt/entity/view.hpp

@@ -359,7 +359,8 @@ public:
      * @return True if the view contains the given entity, false otherwise.
      */
     bool contains(const entity_type entt) const {
-        return find(entt) != end();
+        return (std::get<pool_type<Component> *>(pools)->has(entt) && ...)
+                && (!std::get<pool_type<Exclude> *>(pools)->has(entt) && ...);
     }
 
     /**
@@ -688,7 +689,7 @@ public:
      * @return True if the view contains the given entity, false otherwise.
      */
     bool contains(const entity_type entt) const {
-        return find(entt) != end();
+        return pool->has(entt);
     }
 
     /**