1
0
Эх сурвалжийг харах

sparse_set: further refine pop_all to make it even faster

Michele Caini 3 жил өмнө
parent
commit
bd00e797a9

+ 5 - 5
src/entt/entity/sparse_set.hpp

@@ -301,19 +301,19 @@ protected:
 
     /*! @brief Erases all entities of a sparse set. */
     virtual void pop_all() {
-        if(mode == deletion_policy::swap_and_pop) {
+        if(const auto prev = std::exchange(free_list, tombstone); prev == null) {
             for(auto first = begin(); !(first.index() < 0); ++first) {
-                swap_and_pop(first);
+                sparse_ref(*first) = null;
             }
         } else {
             for(auto first = begin(); !(first.index() < 0); ++first) {
                 if(*first != tombstone) {
-                    in_place_pop(first);
+                    sparse_ref(*first) = null;
                 }
             }
-
-            fast_compact();
         }
+
+        packed.clear();
     }
 
     /**