Michele Caini 8 лет назад
Родитель
Сommit
c588fff5ca
3 измененных файлов с 15 добавлено и 19 удалено
  1. 8 12
      src/entt/entity/registry.hpp
  2. 1 1
      src/entt/process/process.hpp
  3. 6 6
      src/entt/signal/emitter.hpp

+ 8 - 12
src/entt/entity/registry.hpp

@@ -291,10 +291,8 @@ public:
      * @return True if the identifier is still valid, false otherwise.
      */
     bool valid(entity_type entity) const noexcept {
-        using promotion_type = std::conditional_t<sizeof(size_type) >= sizeof(entity_type), size_type, entity_type>;
-        // explicit promotion to avoid warnings with std::uint16_t
-        const auto entt = promotion_type{entity} & traits_type::entity_mask;
-        return (entt < entities.size() && entities[entt] == entity);
+        const auto pos = size_type(entity & traits_type::entity_mask);
+        return (pos < entities.size() && entities[pos] == entity);
     }
 
     /**
@@ -324,11 +322,9 @@ public:
      * @return Actual version for the given entity identifier.
      */
     version_type current(entity_type entity) const noexcept {
-        using promotion_type = std::conditional_t<sizeof(size_type) >= sizeof(entity_type), size_type, entity_type>;
-        // explicit promotion to avoid warnings with std::uint16_t
-        const auto entt = promotion_type{entity} & traits_type::entity_mask;
-        assert(entt < entities.size());
-        return version_type((entities[entt] >> traits_type::entity_shift) & traits_type::version_mask);
+        const auto pos = size_type(entity & traits_type::entity_mask);
+        assert(pos < entities.size());
+        return version_type((entities[pos] >> traits_type::entity_shift) & traits_type::version_mask);
     }
 
     /**
@@ -486,7 +482,7 @@ public:
             tags.resize(ttype + 1);
         }
 
-        tags[ttype].reset(new Attaching<Tag>{entity, Tag{ std::forward<Args>(args)... }});
+        tags[ttype].reset(new Attaching<Tag>{entity, Tag{std::forward<Args>(args)...}});
 
         return static_cast<Attaching<Tag> *>(tags[ttype].get())->tag;
     }
@@ -693,7 +689,7 @@ public:
     template<typename... Component>
     std::enable_if_t<(sizeof...(Component) > 1), std::tuple<const Component &...>>
     get(entity_type entity) const noexcept {
-        return std::tuple<const Component &...>{ get<Component>(entity)... };
+        return std::tuple<const Component &...>{get<Component>(entity)...};
     }
 
     /**
@@ -713,7 +709,7 @@ public:
     template<typename... Component>
     std::enable_if_t<(sizeof...(Component) > 1), std::tuple<Component &...>>
     get(entity_type entity) noexcept {
-        return std::tuple<Component &...>{ get<Component>(entity)... };
+        return std::tuple<Component &...>{get<Component>(entity)...};
     }
 
     /**

+ 1 - 1
src/entt/process/process.hpp

@@ -322,7 +322,7 @@ struct ProcessAdaptor: Process<ProcessAdaptor<Func, Delta>, Delta>, private Func
      * @param data Optional data.
      */
     void update(Delta delta, void *data) {
-        Func::operator()(delta, data, [this](){ this->succeed(); }, [this](){ this->fail(); });
+        Func::operator()(delta, data, [this]() { this->succeed(); }, [this]() { this->fail(); });
     }
 };
 

+ 6 - 6
src/entt/signal/emitter.hpp

@@ -52,7 +52,7 @@ class Emitter {
         using connection_type = typename container_type::iterator;
 
         bool empty() const noexcept override {
-            auto pred = [](auto &&element){ return element.first; };
+            auto pred = [](auto &&element) { return element.first; };
 
             return std::all_of(onceL.cbegin(), onceL.cend(), pred) &&
                     std::all_of(onL.cbegin(), onL.cend(), pred);
@@ -60,7 +60,7 @@ class Emitter {
 
         void clear() noexcept override {
             if(publishing) {
-                auto func = [](auto &&element){ element.first = true; };
+                auto func = [](auto &&element) { element.first = true; };
                 std::for_each(onceL.begin(), onceL.end(), func);
                 std::for_each(onL.begin(), onL.end(), func);
             } else {
@@ -81,7 +81,7 @@ class Emitter {
             conn->first = true;
 
             if(!publishing) {
-                auto pred = [](auto &&element){ return element.first; };
+                auto pred = [](auto &&element) { return element.first; };
                 onceL.remove_if(pred);
                 onL.remove_if(pred);
             }
@@ -102,7 +102,7 @@ class Emitter {
 
             publishing = false;
 
-            onL.remove_if([](auto &&element){ return element.first; });
+            onL.remove_if([](auto &&element) { return element.first; });
         }
 
     private:
@@ -304,7 +304,7 @@ public:
      */
     void clear() noexcept {
         std::for_each(handlers.begin(), handlers.end(),
-                      [](auto &&handler){ if(handler) { handler->clear(); } });
+                      [](auto &&handler) { if(handler) { handler->clear(); } });
     }
 
     /**
@@ -327,7 +327,7 @@ public:
      */
     bool empty() const noexcept {
         return std::all_of(handlers.cbegin(), handlers.cend(),
-                           [](auto &&handler){ return !handler || handler->empty(); });
+                           [](auto &&handler) { return !handler || handler->empty(); });
     }
 
 private: