浏览代码

coding style

skypjack 1 月之前
父节点
当前提交
1ca8b33a75

+ 4 - 4
src/entt/container/dense_map.hpp

@@ -792,13 +792,13 @@ public:
      */
      */
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const key_type &key) {
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const key_type &key) {
         const auto it = find(key);
         const auto it = find(key);
-        return {it, it + !(it == end())};
+        return {it, it + (it != end())};
     }
     }
 
 
     /*! @copydoc equal_range */
     /*! @copydoc equal_range */
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const key_type &key) const {
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const key_type &key) const {
         const auto it = find(key);
         const auto it = find(key);
-        return {it, it + !(it == cend())};
+        return {it, it + (it != cend())};
     }
     }
 
 
     /**
     /**
@@ -811,14 +811,14 @@ public:
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &key)
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &key)
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
         const auto it = find(key);
         const auto it = find(key);
-        return {it, it + !(it == end())};
+        return {it, it + (it != end())};
     }
     }
 
 
     /*! @copydoc equal_range */
     /*! @copydoc equal_range */
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &key) const
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &key) const
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
         const auto it = find(key);
         const auto it = find(key);
-        return {it, it + !(it == cend())};
+        return {it, it + (it != cend())};
     }
     }
 
 
     /**
     /**

+ 4 - 4
src/entt/container/dense_set.hpp

@@ -668,13 +668,13 @@ public:
      */
      */
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const value_type &value) {
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const value_type &value) {
         const auto it = find(value);
         const auto it = find(value);
-        return {it, it + !(it == end())};
+        return {it, it + (it != end())};
     }
     }
 
 
     /*! @copydoc equal_range */
     /*! @copydoc equal_range */
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const value_type &value) const {
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const value_type &value) const {
         const auto it = find(value);
         const auto it = find(value);
-        return {it, it + !(it == cend())};
+        return {it, it + (it != cend())};
     }
     }
 
 
     /**
     /**
@@ -687,14 +687,14 @@ public:
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &value)
     [[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &value)
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
         const auto it = find(value);
         const auto it = find(value);
-        return {it, it + !(it == end())};
+        return {it, it + (it != end())};
     }
     }
 
 
     /*! @copydoc equal_range */
     /*! @copydoc equal_range */
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &value) const
     [[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &value) const
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
     requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
         const auto it = find(value);
         const auto it = find(value);
-        return {it, it + !(it == cend())};
+        return {it, it + (it != cend())};
     }
     }
 
 
     /**
     /**

+ 2 - 2
src/entt/entity/group.hpp

@@ -103,14 +103,14 @@ class group_handler final: public group_descriptor {
     }
     }
 
 
     void push_on_construct(const entity_type entt) {
     void push_on_construct(const entity_type entt) {
-        if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
+        if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && (cpool->index(entt) >= pos) && (other->contains(entt) && ...); }, pools)
            && stl::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
            && stl::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
             swap_elements(len++, entt);
             swap_elements(len++, entt);
         }
         }
     }
     }
 
 
     void push_on_destroy(const entity_type entt) {
     void push_on_destroy(const entity_type entt) {
-        if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
+        if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && (cpool->index(entt) >= pos) && (other->contains(entt) && ...); }, pools)
            && stl::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
            && stl::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
             swap_elements(len++, entt);
             swap_elements(len++, entt);
         }
         }

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

@@ -434,7 +434,7 @@ public:
      */
      */
     bool reset(const id_type id) {
     bool reset(const id_type id) {
         ENTT_ASSERT(id != type_hash<entity_type>::value(), "Cannot reset entity storage");
         ENTT_ASSERT(id != type_hash<entity_type>::value(), "Cannot reset entity storage");
-        return !(pools.erase(id) == 0u);
+        return (pools.erase(id) != 0u);
     }
     }
 
 
     /**
     /**

+ 1 - 1
src/entt/entity/runtime_view.hpp

@@ -222,7 +222,7 @@ public:
      * @return This runtime view.
      * @return This runtime view.
      */
      */
     basic_runtime_view &iterate(common_type &base) {
     basic_runtime_view &iterate(common_type &base) {
-        if(pools.empty() || !(base.size() < pools.front()->size())) {
+        if(pools.empty() || (base.size() >= pools.front()->size())) {
             pools.push_back(&base);
             pools.push_back(&base);
         } else {
         } else {
             pools.push_back(stl::exchange(pools.front(), &base));
             pools.push_back(stl::exchange(pools.front(), &base));

+ 4 - 4
src/entt/entity/sparse_set.hpp

@@ -178,7 +178,7 @@ class basic_sparse_set {
         const auto pos = entity_to_pos(entt);
         const auto pos = entity_to_pos(entt);
         const auto page = pos_to_page(pos);
         const auto page = pos_to_page(pos);
 
 
-        if(!(page < sparse.size())) {
+        if(page >= sparse.size()) {
             sparse.resize(page + 1u, nullptr);
             sparse.resize(page + 1u, nullptr);
         }
         }
 
 
@@ -337,7 +337,7 @@ protected:
                 packed.push_back(entt);
                 packed.push_back(entt);
                 elem = traits_type::combine(static_cast<traits_type::entity_type>(packed.size() - 1u), traits_type::to_integral(entt));
                 elem = traits_type::combine(static_cast<traits_type::entity_type>(packed.size() - 1u), traits_type::to_integral(entt));
             } else {
             } else {
-                ENTT_ASSERT(!(entity_to_pos(elem) < head), "Slot not available");
+                ENTT_ASSERT(entity_to_pos(elem) >= head, "Slot not available");
                 bump(entt);
                 bump(entt);
             }
             }
 
 
@@ -502,7 +502,7 @@ public:
      * @param value Free list information that is mode dependent.
      * @param value Free list information that is mode dependent.
      */
      */
     void free_list(const size_type value) noexcept {
     void free_list(const size_type value) noexcept {
-        ENTT_ASSERT((mode == deletion_policy::swap_only) && !(value > packed.size()), "Invalid value");
+        ENTT_ASSERT((mode == deletion_policy::swap_only) && (value <= packed.size()), "Invalid value");
         head = value;
         head = value;
     }
     }
 
 
@@ -965,7 +965,7 @@ public:
     template<typename Compare, typename Sort = std_sort, typename... Args>
     template<typename Compare, typename Sort = std_sort, typename... Args>
     void sort_n(const size_type length, Compare compare, Sort algo = Sort{}, Args &&...args) {
     void sort_n(const size_type length, Compare compare, Sort algo = Sort{}, Args &&...args) {
         ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
         ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
-        ENTT_ASSERT(!(length > packed.size()), "Length exceeds the number of elements");
+        ENTT_ASSERT(length <= packed.size(), "Length exceeds the number of elements");
 
 
         algo(packed.rend() - static_cast<difference_type>(length), packed.rend(), stl::move(compare), stl::forward<Args>(args)...);
         algo(packed.rend() - static_cast<difference_type>(length), packed.rend(), stl::move(compare), stl::forward<Args>(args)...);
 
 

+ 3 - 3
src/entt/entity/storage.hpp

@@ -220,7 +220,7 @@ class basic_storage: public basic_sparse_set<Entity, typename stl::allocator_tra
     auto assure_at_least(const stl::size_t pos) {
     auto assure_at_least(const stl::size_t pos) {
         const auto idx = pos / traits_type::page_size;
         const auto idx = pos / traits_type::page_size;
 
 
-        if(!(idx < payload.size())) {
+        if(idx >= payload.size()) {
             auto curr = payload.size();
             auto curr = payload.size();
             allocator_type allocator{get_allocator()};
             allocator_type allocator{get_allocator()};
             payload.resize(idx + 1u, nullptr);
             payload.resize(idx + 1u, nullptr);
@@ -346,7 +346,7 @@ protected:
         } else {
         } else {
             allocator_type allocator{get_allocator()};
             allocator_type allocator{get_allocator()};
 
 
-            for(auto first = base_type::begin(); !(first.index() < 0); ++first) {
+            for(auto first = base_type::begin(); first.index() >= 0; ++first) {
                 if constexpr(traits_type::in_place_delete) {
                 if constexpr(traits_type::in_place_delete) {
                     if(*first != tombstone) {
                     if(*first != tombstone) {
                         base_type::in_place_pop(*first);
                         base_type::in_place_pop(*first);
@@ -1131,7 +1131,7 @@ public:
      */
      */
     entity_type generate(const entity_type hint) {
     entity_type generate(const entity_type hint) {
         if(hint != null && hint != tombstone) {
         if(hint != null && hint != tombstone) {
-            if(const auto curr = traits_type::construct(traits_type::to_entity(hint), base_type::current(hint)); curr == tombstone || !(base_type::index(curr) < base_type::free_list())) {
+            if(const auto curr = traits_type::construct(traits_type::to_entity(hint), base_type::current(hint)); curr == tombstone || (base_type::index(curr) >= base_type::free_list())) {
                 return *base_type::try_emplace(hint, true);
                 return *base_type::try_emplace(hint, true);
             }
             }
         }
         }

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

@@ -612,7 +612,7 @@ public:
 
 
     /*! @copydoc any::operator bool */
     /*! @copydoc any::operator bool */
     [[nodiscard]] explicit operator bool() const noexcept {
     [[nodiscard]] explicit operator bool() const noexcept {
-        return !(vtable == nullptr);
+        return (vtable != nullptr);
     }
     }
 
 
     /*! @copydoc any::operator== */
     /*! @copydoc any::operator== */

+ 1 - 1
src/entt/signal/delegate.hpp

@@ -269,7 +269,7 @@ public:
      */
      */
     [[nodiscard]] explicit operator bool() const noexcept {
     [[nodiscard]] explicit operator bool() const noexcept {
         // no need to also test instance
         // no need to also test instance
-        return !(fn == nullptr);
+        return (fn != nullptr);
     }
     }
 
 
     /**
     /**

+ 1 - 1
test/entt/entity/storage.cpp

@@ -1724,7 +1724,7 @@ TYPED_TEST(Storage, ReferencesGuaranteed) {
     ASSERT_EQ(pool.get(entity_type{1}), value_type{1});
     ASSERT_EQ(pool.get(entity_type{1}), value_type{1});
 
 
     for(auto &&elem: pool) {
     for(auto &&elem: pool) {
-        if(!(elem == value_type{})) {
+        if(elem != value_type{}) {
             elem = value_type{4};
             elem = value_type{4};
         }
         }
     }
     }