ソースを参照

group: avoid unnecessary pointer arithmetic

Michele Caini 1 年間 前
コミット
483cc2b913
1 ファイル変更3 行追加3 行削除
  1. 3 3
      src/entt/entity/group.hpp

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

@@ -105,8 +105,8 @@ class group_handler final: public group_descriptor {
     using entity_type = typename Type::entity_type;
 
     void swap_elements(const std::size_t pos, const entity_type entt) {
-        for(std::size_t next{}; next < Owned; ++next) {
-            pools[next]->swap_elements(pools[next]->data()[pos], entt);
+        for(auto first = pools.begin(), last = first + Owned; first != last; ++first) {
+            (*first)->swap_elements((**first)[pos], entt);
         }
     }
 
@@ -132,7 +132,7 @@ class group_handler final: public group_descriptor {
 
     void common_setup() {
         // we cannot iterate backwards because we want to leave behind valid entities in case of owned types
-        for(auto *first = pools[0u]->data(), *last = first + pools[0u]->size(); first != last; ++first) {
+        for(auto first = pools[0u]->rbegin(), last = first + pools[0u]->size(); first != last; ++first) {
             push_on_construct(*first);
         }
     }