Explorar o código

sigh_mixin: further improve ::pop_all

Michele Caini %!s(int64=3) %!d(string=hai) anos
pai
achega
6fc6b2fb35
Modificáronse 1 ficheiros con 4 adicións e 6 borrados
  1. 4 6
      src/entt/entity/mixin.hpp

+ 4 - 6
src/entt/entity/mixin.hpp

@@ -48,15 +48,13 @@ class sigh_mixin final: public Type {
         if(!destruction.empty()) {
         if(!destruction.empty()) {
             ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
             ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
 
 
-            if(Type::policy() == deletion_policy::swap_and_pop) {
-                for(auto &&entt: static_cast<typename Type::base_type &>(*this)) {
-                    destruction.publish(*owner, entt);
-                }
-            } else {
-                for(auto &&entt: static_cast<typename Type::base_type &>(*this)) {
+            for(auto &&entt: static_cast<typename Type::base_type &>(*this)) {
+                if constexpr(Type::traits_type::in_place_delete) {
                     if(entt != tombstone) {
                     if(entt != tombstone) {
                         destruction.publish(*owner, entt);
                         destruction.publish(*owner, entt);
                     }
                     }
+                } else {
+                    destruction.publish(*owner, entt);
                 }
                 }
             }
             }
         }
         }