Explorar o código

snapshot: avoid unnecessary lookups

Michele Caini %!s(int64=3) %!d(string=hai) anos
pai
achega
63d6c2bff6
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      src/entt/entity/snapshot.hpp

+ 2 - 1
src/entt/entity/snapshot.hpp

@@ -45,10 +45,11 @@ class basic_snapshot {
 
     template<typename... Component, typename Archive, typename It, std::size_t... Index>
     void component(Archive &archive, It first, It last, std::index_sequence<Index...>) const {
+        auto storage{std::forward_as_tuple(reg->template storage<Component>()...)};
         std::array<std::size_t, sizeof...(Index)> size{};
 
         for(auto it = first; it != last; ++it) {
-            ((reg->template all_of<Component>(*it) ? ++size[Index] : 0u), ...);
+            ((std::get<Index>(storage).contains(*it) ? ++size[Index] : 0u), ...);
         }
 
         (get<Component>(archive, size[Index], first, last), ...);