From e5f87eb12bdad9dfbf8a825461ac17fdb8457f50 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Thu, 10 Oct 2024 09:57:42 +0200 Subject: [PATCH] AK: Make TemporaryChange not copy the old value twice This is necessary for the next commit (and might even help performance in some very weird cases). --- AK/TemporaryChange.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AK/TemporaryChange.h b/AK/TemporaryChange.h index 2e5d10c7302..5ac3912a7d6 100644 --- a/AK/TemporaryChange.h +++ b/AK/TemporaryChange.h @@ -15,11 +15,11 @@ class TemporaryChange { public: TemporaryChange(T& variable, T value) : m_variable(variable) - , m_old_value(variable) + , m_old_value(move(variable)) { - m_variable = value; + m_variable = move(value); } - ~TemporaryChange() { m_variable = m_old_value; } + ~TemporaryChange() { m_variable = move(m_old_value); } private: T& m_variable;