From 3796f055d607ba6a25d15ec11f99e7fc2dbfded9 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 25 Mar 2024 11:19:45 +0100 Subject: [PATCH] sigh_mixin: avoid using scoped iterators --- src/entt/entity/mixin.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/entt/entity/mixin.hpp b/src/entt/entity/mixin.hpp index d02d65fa2..74e523f8a 100644 --- a/src/entt/entity/mixin.hpp +++ b/src/entt/entity/mixin.hpp @@ -58,16 +58,18 @@ private: void pop_all() final { if(auto ® = owner_or_assert(); !destruction.empty()) { - for(auto it = underlying_type::base_type::begin(0), last = underlying_type::base_type::end(0); it != last; ++it) { - if constexpr(std::is_same_v) { - destruction.publish(reg, *it); - } else { + if constexpr(std::is_same_v) { + for(typename Type::size_type pos{}, last = Type::free_list(); pos < last; ++pos) { + destruction.publish(reg, underlying_type::base_type::operator[](pos)); + } + } else { + for(auto entt: static_cast(*this)) { if constexpr(component_traits::in_place_delete) { - if(const auto entt = *it; entt != tombstone) { + if(entt != tombstone) { destruction.publish(reg, entt); } } else { - destruction.publish(reg, *it); + destruction.publish(reg, entt); } } }