Browse Source

*: cleanup, minor changes

Michele Caini 4 years ago
parent
commit
c538067544
2 changed files with 9 additions and 14 deletions
  1. 7 12
      src/entt/entity/sparse_set.hpp
  2. 2 2
      src/entt/meta/factory.hpp

+ 7 - 12
src/entt/entity/sparse_set.hpp

@@ -531,13 +531,10 @@ public:
      * @return True if the sparse set contains the entity, false otherwise.
      * @return True if the sparse set contains the entity, false otherwise.
      */
      */
     [[nodiscard]] bool contains(const entity_type entt) const ENTT_NOEXCEPT {
     [[nodiscard]] bool contains(const entity_type entt) const ENTT_NOEXCEPT {
-        if(auto elem = sparse_ptr(entt); elem) {
-            constexpr auto cap = entity_traits::to_entity(entt::null);
-            // testing versions permits to avoid accessing the packed array
-            return (((~cap & entity_traits::to_integral(entt)) ^ entity_traits::to_integral(*elem)) < cap);
-        }
-
-        return false;
+        const auto elem = sparse_ptr(entt);
+        constexpr auto cap = entity_traits::to_entity(null);
+        // testing versions permits to avoid accessing the packed array
+        return elem && (((~cap & entity_traits::to_integral(entt)) ^ entity_traits::to_integral(*elem)) < cap);
     }
     }
 
 
     /**
     /**
@@ -547,11 +544,9 @@ public:
      * version otherwise.
      * version otherwise.
      */
      */
     [[nodiscard]] version_type current(const entity_type entt) const {
     [[nodiscard]] version_type current(const entity_type entt) const {
-        if(auto elem = sparse_ptr(entt); elem) {
-            return entity_traits::to_version(*elem);
-        }
-
-        return entity_traits::to_version(tombstone);
+        const auto elem = sparse_ptr(entt);
+        constexpr auto fallback = entity_traits::to_version(tombstone);
+        return elem ? entity_traits::to_version(*elem) : fallback;
     }
     }
 
 
     /**
     /**

+ 2 - 2
src/entt/meta/factory.hpp

@@ -241,10 +241,10 @@ public:
             internal::meta_node<Base>::resolve(),
             internal::meta_node<Base>::resolve(),
             [](meta_any other) ENTT_NOEXCEPT -> meta_any {
             [](meta_any other) ENTT_NOEXCEPT -> meta_any {
                 if(auto *data = other.data(); data) {
                 if(auto *data = other.data(); data) {
-                    return entt::forward_as_meta(*static_cast<Base *>(static_cast<Type *>(data)));
+                    return forward_as_meta(*static_cast<Base *>(static_cast<Type *>(data)));
                 }
                 }
 
 
-                return entt::forward_as_meta(*static_cast<const Base *>(static_cast<const Type *>(std::as_const(other).data())));
+                return forward_as_meta(*static_cast<const Base *>(static_cast<const Type *>(std::as_const(other).data())));
             }
             }
             // tricks clang-format
             // tricks clang-format
         };
         };