Parcourir la source

snapshot: also avoid using views if not required

Michele Caini il y a 3 ans
Parent
commit
cc45e73414
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      src/entt/entity/snapshot.hpp

+ 3 - 3
src/entt/entity/snapshot.hpp

@@ -33,12 +33,12 @@ class basic_snapshot {
 
     template<typename Component, typename Archive, typename It>
     void get(Archive &archive, std::size_t sz, It first, It last) const {
-        const auto view = reg->template view<const Component>();
+        const auto &storage = reg->template storage<Component>();
         archive(static_cast<typename traits_type::entity_type>(sz));
 
         for(auto it = first; it != last; ++it) {
-            if(view.contains(*it)) {
-                std::apply(archive, std::tuple_cat(std::make_tuple(*it), view.get(*it)));
+            if(storage.contains(*it)) {
+                std::apply(archive, std::tuple_cat(std::make_tuple(*it), storage.get_as_tuple(*it)));
             }
         }
     }