瀏覽代碼

*: use c-style arrays where it makes sense

Michele Caini 1 年之前
父節點
當前提交
96250f0abb
共有 4 個文件被更改,包括 8 次插入10 次删除
  1. 2 3
      src/entt/core/algorithm.hpp
  2. 3 3
      src/entt/entity/organizer.hpp
  3. 2 3
      src/entt/entity/sparse_set.hpp
  4. 1 1
      src/entt/entity/view.hpp

+ 2 - 3
src/entt/core/algorithm.hpp

@@ -2,7 +2,6 @@
 #define ENTT_CORE_ALGORITHM_HPP
 
 #include <algorithm>
-#include <array>
 #include <functional>
 #include <iterator>
 #include <utility>
@@ -105,8 +104,8 @@ struct radix_sort {
                 constexpr auto mask = (1 << Bit) - 1;
                 constexpr auto buckets = 1 << Bit;
 
-                std::array<std::size_t, buckets> index{};
-                std::array<std::size_t, buckets> count{};
+                std::size_t index[buckets]{};
+                std::size_t count[buckets]{};
 
                 for(auto it = from; it != to; ++it) {
                     ++count[(getter(*it) >> start) & mask];

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

@@ -1,7 +1,6 @@
 #ifndef ENTT_ENTITY_ORGANIZER_HPP
 #define ENTT_ENTITY_ORGANIZER_HPP
 
-#include <array>
 #include <cstddef>
 #include <type_traits>
 #include <utility>
@@ -135,8 +134,9 @@ class basic_organizer final {
         if constexpr(sizeof...(Type) == 0u) {
             return {};
         } else {
-            std::array info{&type_id<Type>()...};
-            const auto length = count < info.size() ? count : info.size();
+            const type_info *info[]{&type_id<Type>()...};
+            constexpr auto extent = std::extent_v<decltype(info)>;
+            const auto length = count < extent ? count : extent;
 
             for(std::size_t pos{}; pos < length; ++pos) {
                 buffer[pos] = info[pos];

+ 2 - 3
src/entt/entity/sparse_set.hpp

@@ -1,7 +1,6 @@
 #ifndef ENTT_ENTITY_SPARSE_SET_HPP
 #define ENTT_ENTITY_SPARSE_SET_HPP
 
-#include <array>
 #include <cstddef>
 #include <iterator>
 #include <memory>
@@ -998,7 +997,7 @@ public:
      */
     template<typename Compare, typename Sort = std_sort, typename... Args>
     void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
-        const std::array len{packed.size(), head};
+        const size_type len[]{packed.size(), head};
         sort_n(len[mode == deletion_policy::swap_only], std::move(compare), std::move(algo), std::forward<Args>(args)...);
     }
 
@@ -1018,7 +1017,7 @@ public:
     template<typename It>
     iterator sort_as(It first, It last) {
         ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
-        const std::array len{packed.size(), head};
+        const size_type len[]{packed.size(), head};
         auto it = end() - static_cast<typename iterator::difference_type>(len[mode == deletion_policy::swap_only]);
 
         for(const auto other = end(); (it != other) && (first != last); ++first) {

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

@@ -223,7 +223,7 @@ class basic_common_view {
     [[nodiscard]] auto offset() const noexcept {
         ENTT_ASSERT(index != Get, "Invalid view");
         const auto *view = pools[index];
-        const std::array len{view->size(), view->free_list()};
+        const size_type len[]{view->size(), view->free_list()};
         return len[view->policy() == deletion_policy::swap_only];
     }