1
0
Эх сурвалжийг харах

snapshot: avoid unnecessary lookups

Michele Caini 3 жил өмнө
parent
commit
63d6c2bff6

+ 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>
     template<typename... Component, typename Archive, typename It, std::size_t... Index>
     void component(Archive &archive, It first, It last, std::index_sequence<Index...>) const {
     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{};
         std::array<std::size_t, sizeof...(Index)> size{};
 
 
         for(auto it = first; it != last; ++it) {
         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), ...);
         (get<Component>(archive, size[Index], first, last), ...);