Browse Source

sparse_set: make ::pop_all check pages before filling them

skypjack 5 days ago
parent
commit
9c5281c79a
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/entt/entity/sparse_set.hpp

+ 4 - 2
src/entt/entity/sparse_set.hpp

@@ -297,8 +297,10 @@ protected:
         if(!packed.empty()) {
             // suboptimal with few entities, but exploits cache way more with many
             for(auto &&elem: sparse) {
-                for(size_type pos{}; pos < traits_type::page_size; ++pos) {
-                    elem[pos] = null;
+                if(elem) {
+                    for(size_type pos{}; pos < traits_type::page_size; ++pos) {
+                        elem[pos] = null;
+                    }
                 }
             }
         }