From cab51d26cc4f106ee5cb516f9655ede6e48357ce Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 10 Jun 2017 22:33:14 +0400 Subject: [PATCH] Doors: small key search optimizations --- apps/openmw/mwclass/door.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 5f977174f..bbaff6338 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -132,15 +132,19 @@ namespace MWClass // make key id lowercase std::string keyId = ptr.getCellRef().getKey(); - Misc::StringUtils::lowerCaseInPlace(keyId); - for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it) + if (!keyId.empty()) { - std::string refId = it->getCellRef().getRefId(); - Misc::StringUtils::lowerCaseInPlace(refId); - if (refId == keyId) + Misc::StringUtils::lowerCaseInPlace(keyId); + for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it) { - hasKey = true; - keyName = it->getClass().getName(*it); + std::string refId = it->getCellRef().getRefId(); + Misc::StringUtils::lowerCaseInPlace(refId); + if (refId == keyId) + { + hasKey = true; + keyName = it->getClass().getName(*it); + break; + } } }