Explorar el Código

slightly faster destroy

Michele Caini hace 7 años
padre
commit
8d08ffc4ae
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      src/entt/entity/storage.hpp

+ 2 - 1
src/entt/entity/storage.hpp

@@ -370,7 +370,8 @@ public:
      * @param entt A valid entity identifier.
      * @param entt A valid entity identifier.
      */
      */
     void destroy(const entity_type entt) override {
     void destroy(const entity_type entt) override {
-        std::swap(instances[underlying_type::get(entt)], instances.back());
+        auto other = std::move(instances.back());
+        instances[underlying_type::get(entt)] = std::move(other);
         instances.pop_back();
         instances.pop_back();
         underlying_type::destroy(entt);
         underlying_type::destroy(entt);
     }
     }