From 0019f3831e97209fd10ccae2cbfaa0a2b7ec1341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Wed, 24 Dec 2025 18:26:46 +0100 Subject: [PATCH] Codechange: [Script] Reuse memory when changing values of ScriptList items (#14966) --- src/script/api/script_list.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/script/api/script_list.cpp b/src/script/api/script_list.cpp index 8f102ff410..92b3dd4a50 100644 --- a/src/script/api/script_list.cpp +++ b/src/script/api/script_list.cpp @@ -560,9 +560,10 @@ bool ScriptList::SetValue(SQInteger item, SQInteger value) this->sorter->Remove(item); auto value_iter = this->values.find({value_old, item}); assert(value_iter != this->values.end()); - this->values.erase(value_iter); item_iter->second = value; - this->values.emplace(value, item); + auto node_handle = this->values.extract(value_iter); + node_handle.value().first = value; + this->values.insert(std::move(node_handle)); return true; }