Просмотр исходного кода

snapshot: avoid multiple lookups of the same storage

Michele Caini 2 лет назад
Родитель
Сommit
e4f51f2b7f
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      src/entt/entity/snapshot.hpp

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

@@ -340,9 +340,11 @@ class basic_continuous_loader {
 
     void destroy(typename Registry::entity_type entt) {
         if(const auto it = remloc.find(entt); it == remloc.cend()) {
-            const auto local = reg->create();
+            auto &storage = reg->template storage<entity_type>();
+            const auto local = storage.emplace();
+
             remloc.emplace(entt, std::make_pair(local, true));
-            reg->destroy(local);
+            storage.erase(local);
         }
     }