1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 08:52:40 +01:00

Codechange: [Script] Reuse memory when changing values of ScriptList items (#14966)

This commit is contained in:
Loïc Guilloux
2025-12-24 18:26:46 +01:00
committed by GitHub
parent 900192e2cd
commit 0019f3831e

View File

@@ -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;
}