Explorar o código

slightly improved registry::replace (thanks to ColinH for pointing it out)

Michele Caini %!s(int64=6) %!d(string=hai) anos
pai
achega
77ea28bef2
Modificáronse 2 ficheiros con 2 adicións e 3 borrados
  1. 1 0
      AUTHORS
  2. 1 3
      src/entt/entity/registry.hpp

+ 1 - 0
AUTHORS

@@ -7,6 +7,7 @@ skypjack
 BenediktConze
 BenediktConze
 bjadamson
 bjadamson
 ceeac
 ceeac
+ColinH
 corystegel
 corystegel
 Croydon
 Croydon
 dbacchet
 dbacchet

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

@@ -98,9 +98,7 @@ class basic_registry {
         Component & replace(const Entity entt, Args &&... args) {
         Component & replace(const Entity entt, Args &&... args) {
             Component component{std::forward<Args>(args)...};
             Component component{std::forward<Args>(args)...};
             on_replace.publish(*owner, entt, component);
             on_replace.publish(*owner, entt, component);
-            auto &other = sparse_set<Entity, Component>::get(entt);
-            std::swap(other, component);
-            return other;
+            return (sparse_set<Entity, Component>::get(entt) = std::move(component));
         }
         }
     };
     };