From 86fbf05b0937d22cd329ba54f39c4142d4ae3faf Mon Sep 17 00:00:00 2001 From: Mateusz Karbowiak Date: Fri, 8 Dec 2023 20:49:47 +0100 Subject: [PATCH 1/2] Fix general swapping function --- Source/Engine/Core/Templates.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Core/Templates.h b/Source/Engine/Core/Templates.h index 75674e2d0..876a4db83 100644 --- a/Source/Engine/Core/Templates.h +++ b/Source/Engine/Core/Templates.h @@ -304,7 +304,7 @@ template inline void Swap(T& a, T& b) noexcept { T tmp = MoveTemp(a); - a = b; + a = MoveTemp(b); b = MoveTemp(tmp); } From f3497a2a553e3557cc179894354dff0258daa1bb Mon Sep 17 00:00:00 2001 From: Mateusz Karbowiak Date: Fri, 8 Dec 2023 20:50:52 +0100 Subject: [PATCH 2/2] Fix swapping core collections --- Source/Engine/Core/Collections/Array.h | 4 +--- Source/Engine/Core/Collections/Dictionary.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Core/Collections/Array.h b/Source/Engine/Core/Collections/Array.h index cf45ed060..a8390f051 100644 --- a/Source/Engine/Core/Collections/Array.h +++ b/Source/Engine/Core/Collections/Array.h @@ -734,9 +734,7 @@ public: } else { - Array tmp = MoveTemp(other); - other = *this; - *this = MoveTemp(tmp); + ::Swap(other, *this); } } diff --git a/Source/Engine/Core/Collections/Dictionary.h b/Source/Engine/Core/Collections/Dictionary.h index dd73be390..d2a840fff 100644 --- a/Source/Engine/Core/Collections/Dictionary.h +++ b/Source/Engine/Core/Collections/Dictionary.h @@ -616,9 +616,7 @@ public: } else { - Dictionary tmp = MoveTemp(other); - other = *this; - *this = MoveTemp(tmp); + ::Swap(other, *this); } }