From 7daef583cb4238e425176e6d66bac959fc596b20 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 3 Mar 2023 13:34:40 +0100 Subject: [PATCH] Use ESM::RefId as key for ScriptContext::mLocals --- apps/opencs/model/world/scriptcontext.cpp | 6 +++--- apps/opencs/model/world/scriptcontext.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/scriptcontext.cpp b/apps/opencs/model/world/scriptcontext.cpp index 7f554a75af..ba70127ad3 100644 --- a/apps/opencs/model/world/scriptcontext.cpp +++ b/apps/opencs/model/world/scriptcontext.cpp @@ -85,7 +85,7 @@ std::pair CSMWorld::ScriptContext::getMemberType(const std::string& if (index == -1) return std::make_pair(' ', false); - std::map::iterator iter = mLocals.find(id2.getRefIdString()); + auto iter = mLocals.find(id2); if (iter == mLocals.end()) { @@ -97,7 +97,7 @@ std::pair CSMWorld::ScriptContext::getMemberType(const std::string& Compiler::Scanner scanner(errorHandler, stream, getExtensions()); scanner.scan(parser); - iter = mLocals.insert(std::make_pair(id2.getRefIdString(), locals)).first; + iter = mLocals.emplace(id2, std::move(locals)).first; } return std::make_pair(iter->second.getType(Misc::StringUtils::lowerCase(name)), reference); @@ -131,7 +131,7 @@ void CSMWorld::ScriptContext::clear() bool CSMWorld::ScriptContext::clearLocals(const std::string& script) { - std::map::iterator iter = mLocals.find(script); + const auto iter = mLocals.find(script); if (iter != mLocals.end()) { diff --git a/apps/opencs/model/world/scriptcontext.hpp b/apps/opencs/model/world/scriptcontext.hpp index 523a2bf3ac..c2dbadfc6f 100644 --- a/apps/opencs/model/world/scriptcontext.hpp +++ b/apps/opencs/model/world/scriptcontext.hpp @@ -19,7 +19,7 @@ namespace CSMWorld const Data& mData; mutable std::vector mIds; mutable bool mIdsUpdated; - mutable std::map mLocals; + mutable std::map> mLocals; public: ScriptContext(const Data& data);