Просмотр исходного кода

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

Michele Caini 6 лет назад
Родитель
Сommit
77ea28bef2
2 измененных файлов с 2 добавлено и 3 удалено
  1. 1 0
      AUTHORS
  2. 1 3
      src/entt/entity/registry.hpp

+ 1 - 0
AUTHORS

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

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

@@ -98,9 +98,7 @@ class basic_registry {
         Component & replace(const Entity entt, Args &&... args) {
             Component component{std::forward<Args>(args)...};
             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));
         }
     };