From bda52701f50f2da8dffbbd6f73cd241a6eae6276 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 24 Mar 2023 16:45:41 +0100 Subject: [PATCH] snapshot: avoid unnecessary lookups --- src/entt/entity/snapshot.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/entt/entity/snapshot.hpp b/src/entt/entity/snapshot.hpp index 70b412def..db0f8b804 100644 --- a/src/entt/entity/snapshot.hpp +++ b/src/entt/entity/snapshot.hpp @@ -86,13 +86,14 @@ public: */ template const basic_snapshot &entities(Archive &archive) const { - const auto sz = static_cast(reg->size()); - const auto released = static_cast(reg->released()); + const auto &storage = reg->template storage(); + const auto sz = static_cast(storage.size()); + const auto released = static_cast(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); }