Michele Caini 3 лет назад
Родитель
Сommit
1476d4ea9b
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      src/entt/entity/sparse_set.hpp

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

@@ -978,14 +978,14 @@ public:
         const auto to = other.end();
         auto from = other.begin();
 
-        for(size_type pos = packed.size() - 1; pos && from != to; ++from) {
-            if(contains(*from)) {
-                if(*from != packed[pos]) {
+        for(auto it = begin(); it.index() && from != to; ++from) {
+            if(const auto curr = *from; contains(curr)) {
+                if(const auto entt = *it; entt != curr) {
                     // basic no-leak guarantee (with invalid state) if swapping throws
-                    swap_elements(packed[pos], *from);
+                    swap_elements(entt, curr);
                 }
 
-                --pos;
+                ++it;
             }
         }
     }