snapshot: avoid unnecessary lookups

This commit is contained in:
Michele Caini
2023-03-24 16:45:41 +01:00
parent d26f7684ce
commit bda52701f5

View File

@@ -86,13 +86,14 @@ public:
*/
template<typename Archive>
const basic_snapshot &entities(Archive &archive) const {
const auto sz = static_cast<typename traits_type::entity_type>(reg->size());
const auto released = static_cast<typename traits_type::entity_type>(reg->released());
const auto &storage = reg->template storage<entity_type>();
const auto sz = static_cast<typename traits_type::entity_type>(storage.size());
const auto released = static_cast<typename traits_type::entity_type>(sz - storage.in_use());
archive(sz);
archive(released);
for(auto first = reg->data(), last = first + sz; first != last; ++first) {
for(auto first = storage.data(), last = first + sz; first != last; ++first) {
archive(*first);
}