Sfoglia il codice sorgente

snapshot: again, dense_map::contains is a thing

Michele Caini 2 anni fa
parent
commit
63b300d39d
1 ha cambiato i file con 5 aggiunte e 7 eliminazioni
  1. 5 7
      src/entt/entity/snapshot.hpp

+ 5 - 7
src/entt/entity/snapshot.hpp

@@ -319,18 +319,16 @@ class basic_continuous_loader {
     using traits_type = typename Registry::traits_type;
 
     void restore(typename Registry::entity_type entt) {
-        const auto it = remloc.find(entt);
-
-        if(it == remloc.cend()) {
-            const auto local = reg->create();
-            remloc.emplace(entt, std::make_pair(local, true));
-        } else {
+        if(remloc.contains(entt)) {
             if(!reg->valid(remloc[entt].first)) {
                 remloc[entt].first = reg->create();
             }
 
             // set the dirty flag
             remloc[entt].second = true;
+        } else {
+            const auto local = reg->create();
+            remloc.emplace(entt, std::make_pair(local, true));
         }
     }
 
@@ -437,7 +435,7 @@ public:
             for(std::size_t pos = in_use; pos < length; ++pos) {
                 archive(entt);
 
-                if(const auto it = remloc.find(entt); it == remloc.cend()) {
+                if(!remloc.contains(entt)) {
                     const auto local = storage.emplace();
                     remloc.emplace(entt, std::make_pair(local, true));
                     storage.erase(local);