diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index fa47d6626..c53ced146 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -1,7 +1,6 @@ #ifndef ENTT_ENTITY_SNAPSHOT_HPP #define ENTT_ENTITY_SNAPSHOT_HPP -#include #include #include #include @@ -31,30 +30,6 @@ template class basic_snapshot { using traits_type = typename Registry::traits_type; - template - void get(Archive &archive, std::size_t sz, It first, It last) const { - const auto view = reg->template view(); - archive(static_cast(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))); - } - } - } - - template - void component(Archive &archive, It first, It last, std::index_sequence) const { - const auto view{std::make_tuple(reg->template view()...)}; - std::array size{}; - - for(auto it = first; it != last; ++it) { - ((std::get(view).contains(*it) ? ++size[Index] : 0u), ...); - } - - (get(archive, size[Index], first, last), ...); - } - public: /*! Basic registry type. */ using registry_type = Registry; @@ -147,7 +122,21 @@ public: */ template const basic_snapshot &component(Archive &archive, It first, It last) const { - component(archive, first, last, std::index_sequence_for{}); + const auto view = reg->template view(); + std::size_t size{}; + + for(auto it = first; it != last; ++it) { + size += view.contains(*it); + } + + archive(static_cast(size)); + + for(auto it = first; it != last; ++it) { + if(view.contains(*it)) { + std::apply(archive, std::tuple_cat(std::make_tuple(*it), view.get(*it))); + } + } + return *this; }