Преглед на файлове

snapshot: review ::orphans functions

Michele Caini преди 3 години
родител
ревизия
295c68841c
променени са 1 файла, в които са добавени 10 реда и са изтрити 6 реда
  1. 10 6
      src/entt/entity/snapshot.hpp

+ 10 - 6
src/entt/entity/snapshot.hpp

@@ -265,11 +265,13 @@ public:
      * @return A valid loader to continue restoring data.
      */
     const basic_snapshot_loader &orphans() const {
-        reg->each([this](const auto entt) {
+        auto &entities = reg->template storage<entity_type>();
+
+        for(auto entt: entities) {
             if(reg->orphan(entt)) {
-                reg->release(entt);
+                entities.erase(entt);
             }
-        });
+        }
 
         return *this;
     }
@@ -523,11 +525,13 @@ public:
      * @return A non-const reference to this loader.
      */
     basic_continuous_loader &orphans() {
-        reg->each([this](const auto entt) {
+        auto &entities = reg->template storage<entity_type>();
+
+        for(auto entt: entities) {
             if(reg->orphan(entt)) {
-                reg->release(entt);
+                entities.erase(entt);
             }
-        });
+        }
 
         return *this;
     }