From 191f207e78ecd837379be8ab3822190fb415719e Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 3 Mar 2023 13:36:03 +0100 Subject: [PATCH] Avoid redundant conversion to lower case for CommandDispatcher::mSelection items --- apps/opencs/model/world/commanddispatcher.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index 71b27cc812..b211477caf 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -113,11 +113,7 @@ void CSMWorld::CommandDispatcher::setEditLock(bool locked) void CSMWorld::CommandDispatcher::setSelection(const std::vector& selection) { mSelection = selection; - for (auto& sel : mSelection) - { - Misc::StringUtils::lowerCaseInPlace(sel); - } - std::sort(mSelection.begin(), mSelection.end()); + std::sort(mSelection.begin(), mSelection.end(), Misc::StringUtils::CiComp{}); } void CSMWorld::CommandDispatcher::setExtendedTypes(const std::vector& types) @@ -290,8 +286,7 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete() if (record.mState == RecordBase::State_Deleted) continue; - if (!std::binary_search(mSelection.begin(), mSelection.end(), - Misc::StringUtils::lowerCase(record.get().mCell.getRefIdString()))) + if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell)) continue; macro.push(new CSMWorld::DeleteCommand(model, record.get().mId.getRefIdString())); @@ -321,8 +316,7 @@ void CSMWorld::CommandDispatcher::executeExtendedRevert() { const Record& record = collection.getRecord(i); - if (!std::binary_search(mSelection.begin(), mSelection.end(), - Misc::StringUtils::lowerCase(record.get().mCell.getRefIdString()))) + if (!std::binary_search(mSelection.begin(), mSelection.end(), record.get().mCell)) continue; macro.push(new CSMWorld::RevertCommand(model, record.get().mId.getRefIdString()));