Procházet zdrojové kódy

registry: avoid else after return

Michele Caini před 1 rokem
rodič
revize
28adaa5a8b
1 změnil soubory, kde provedl 15 přidání a 15 odebrání
  1. 15 15
      src/entt/entity/registry.hpp

+ 15 - 15
src/entt/entity/registry.hpp

@@ -250,25 +250,25 @@ class basic_registry {
         } else {
             using storage_type = storage_for_type<Type>;
 
-            if(auto it = pools.find(id); it == pools.cend()) {
-                using alloc_type = typename storage_type::allocator_type;
-                typename pool_container_type::mapped_type cpool{};
-
-                if constexpr(std::is_void_v<Type> && !std::is_constructible_v<alloc_type, allocator_type>) {
-                    // std::allocator<void> has no cross constructors (waiting for C++20)
-                    cpool = std::allocate_shared<storage_type>(get_allocator(), alloc_type{});
-                } else {
-                    cpool = std::allocate_shared<storage_type>(get_allocator(), get_allocator());
-                }
+            if(auto it = pools.find(id); it != pools.cend()) {
+                ENTT_ASSERT(it->second->type() == type_id<Type>(), "Unexpected type");
+                return static_cast<storage_type &>(*it->second);
+            }
 
-                pools.emplace(id, cpool);
-                cpool->bind(*this);
+            using alloc_type = typename storage_type::allocator_type;
+            typename pool_container_type::mapped_type cpool{};
 
-                return static_cast<storage_type &>(*cpool);
+            if constexpr(std::is_void_v<Type> && !std::is_constructible_v<alloc_type, allocator_type>) {
+                // std::allocator<void> has no cross constructors (waiting for C++20)
+                cpool = std::allocate_shared<storage_type>(get_allocator(), alloc_type{});
             } else {
-                ENTT_ASSERT(it->second->type() == type_id<Type>(), "Unexpected type");
-                return static_cast<storage_type &>(*it->second);
+                cpool = std::allocate_shared<storage_type>(get_allocator(), get_allocator());
             }
+
+            pools.emplace(id, cpool);
+            cpool->bind(*this);
+
+            return static_cast<storage_type &>(*cpool);
         }
     }