diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 7e75dffffc..610d2ab807 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -186,7 +186,7 @@ void CSMDoc::WriteDialogueCollectionStage::perform(int stage, Messages& messages { CSMWorld::InfoCollection::RecordConstIterator prev = iter; --prev; - std::string prevIdString = (*prev)->get().mId.getRefIdString(); + std::string_view prevIdString = (*prev)->get().mId.getRefIdString(); info.mPrev = ESM::RefId::stringRefId(prevIdString.substr(prevIdString.find_last_of('#') + 1)); } @@ -196,7 +196,7 @@ void CSMDoc::WriteDialogueCollectionStage::perform(int stage, Messages& messages info.mNext = ESM::RefId::sEmpty; if (next != range.second) { - std::string nextIdString = (*next)->get().mId.getRefIdString(); + std::string_view nextIdString = (*next)->get().mId.getRefIdString(); info.mNext = ESM::RefId::stringRefId(nextIdString.substr(nextIdString.find_last_of('#') + 1)); } diff --git a/apps/opencs/model/tools/mergestages.cpp b/apps/opencs/model/tools/mergestages.cpp index 3f9cff4d96..e11be72d4e 100644 --- a/apps/opencs/model/tools/mergestages.cpp +++ b/apps/opencs/model/tools/mergestages.cpp @@ -117,7 +117,7 @@ void CSMTools::MergeReferencesStage::perform(int stage, CSMDoc::Messages& messag ref.mOriginalCell = ref.mCell; - ref.mRefNum.mIndex = mIndex[ref.mCell.getRefIdString()]++; + ref.mRefNum.mIndex = mIndex[Misc::StringUtils::lowerCase(ref.mCell.getRefIdString())]++; ref.mRefNum.mContentFile = 0; ref.mNew = false; diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index 3eeefd5348..8249597b8a 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -909,8 +909,8 @@ void CSMTools::ReferenceableCheckStage::inventoryListCheck( { for (size_t i = 0; i < itemList.size(); ++i) { - ESM::RefId item = itemList[i].mItem; - auto itemName = item.getRefIdString(); + const ESM::RefId& item = itemList[i].mItem; + const auto& itemName = item.getRefIdString(); CSMWorld::RefIdData::LocalIndex localIndex = mReferencables.searchId(item); if (localIndex.first == -1) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index db64988179..c4288b117c 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -331,7 +331,7 @@ namespace CSMWorld { auto id = IdAccessorT().getId(record); - auto iter = mIndex.find(id.getRefIdString()); + auto iter = mIndex.find(Misc::StringUtils::lowerCase(id.getRefIdString())); if (iter == mIndex.end()) { @@ -490,7 +490,8 @@ namespace CSMWorld int Collection::searchId(const ESM::RefId& id) const { - std::map::const_iterator iter = mIndex.find(id.getRefIdString()); + std::map::const_iterator iter + = mIndex.find(Misc::StringUtils::lowerCase(id.getRefIdString())); if (iter == mIndex.end()) return -1; @@ -554,7 +555,7 @@ namespace CSMWorld throw std::runtime_error("index out of range"); std::unique_ptr> record2(static_cast*>(record.release())); - std::string id = IdAccessorT().getId(record2->get()).getRefIdString(); + std::string id = Misc::StringUtils::lowerCase(IdAccessorT().getId(record2->get()).getRefIdString()); if (index == size) mRecords.push_back(std::move(record2)); diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 7a209a1ed5..64be1f32a4 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -380,7 +380,7 @@ void CSVRender::PagedWorldspaceWidget::landDataChanged(const QModelIndex& topLef { for (int r = topLeft.row(); r <= bottomRight.row(); ++r) { - auto id = mDocument.getData().getLand().getId(r); + const auto& id = mDocument.getData().getLand().getId(r); auto cellIt = mCells.find(CSMWorld::CellCoordinates::fromId(id.getRefIdString()).first); if (cellIt != mCells.end()) @@ -395,7 +395,7 @@ void CSVRender::PagedWorldspaceWidget::landAboutToBeRemoved(const QModelIndex& p { for (int r = start; r <= end; ++r) { - auto id = mDocument.getData().getLand().getId(r); + const auto& id = mDocument.getData().getLand().getId(r); auto cellIt = mCells.find(CSMWorld::CellCoordinates::fromId(id.getRefIdString()).first); if (cellIt != mCells.end()) @@ -410,7 +410,7 @@ void CSVRender::PagedWorldspaceWidget::landAdded(const QModelIndex& parent, int { for (int r = start; r <= end; ++r) { - auto id = mDocument.getData().getLand().getId(r); + const auto& id = mDocument.getData().getLand().getId(r); auto cellIt = mCells.find(CSMWorld::CellCoordinates::fromId(id.getRefIdString()).first); if (cellIt != mCells.end()) diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 987d880965..d6879c9668 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -259,7 +259,7 @@ namespace CSVRender { CSMWorld::IdTree* model = &dynamic_cast(*mData.getTableModel(CSMWorld::UniversalId::Type_Pathgrids)); - std::string idString = mId.getRefIdString(); + const std::string& idString = mId.getRefIdString(); const CSMWorld::Pathgrid* source = getPathgridSource(); if (source) { diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index f1bf8f783f..d019e65b5f 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -757,7 +757,7 @@ namespace MWRender bool NpcAnimation::isFirstPersonPart(const ESM::BodyPart* bodypart) { - const auto partName = bodypart->mId.getRefIdString(); + std::string_view partName = bodypart->mId.getRefIdString(); return partName.size() >= 3 && partName.substr(partName.size() - 3, 3) == "1st"; } diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 754f0193f8..38847515ba 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -30,7 +30,7 @@ namespace auto& scripts = MWBase::Environment::get().getWorld()->getLocalScripts(); for (const auto&& ptr : store) { - auto script = ptr.getClass().getScript(ptr); + const auto& script = ptr.getClass().getScript(ptr); if (!script.empty()) { MWWorld::Ptr item = ptr; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index a1f0933722..e62e383e54 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -801,7 +801,7 @@ namespace MWWorld MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference); for (MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it) { - auto script = it->getClass().getScript(*it); + const auto& script = it->getClass().getScript(*it); if (!script.empty()) { MWWorld::Ptr item = *it; @@ -844,7 +844,7 @@ namespace MWWorld MWWorld::ContainerStore& container = reference.getClass().getContainerStore(reference); for (MWWorld::ContainerStoreIterator it = container.begin(); it != container.end(); ++it) { - auto script = it->getClass().getScript(*it); + const ESM::RefId& script = it->getClass().getScript(*it); if (!script.empty()) { MWWorld::Ptr item = *it; @@ -1128,7 +1128,7 @@ namespace MWWorld && ptr.getRefData().isEnabled()) { mWorldScene->addObjectToScene(ptr); - auto script = ptr.getClass().getScript(ptr); + const auto& script = ptr.getClass().getScript(ptr); if (!script.empty()) mLocalScripts.add(script, ptr); addContainerScripts(ptr, ptr.getCell()); @@ -1189,7 +1189,7 @@ namespace MWWorld if (newPtr.getRefData().isEnabled()) mWorldScene->addObjectToScene(newPtr); - auto script = newPtr.getClass().getScript(newPtr); + const auto& script = newPtr.getClass().getScript(newPtr); if (!script.empty()) { mLocalScripts.add(script, newPtr); @@ -1219,7 +1219,7 @@ namespace MWWorld MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager(); mechMgr->updateCell(ptr, newPtr); - auto script = ptr.getClass().getScript(ptr); + const auto& script = ptr.getClass().getScript(ptr); if (!script.empty()) { mLocalScripts.remove(ptr); @@ -2135,7 +2135,7 @@ namespace MWWorld void World::PCDropped(const Ptr& item) { - auto script = item.getClass().getScript(item); + const auto& script = item.getClass().getScript(item); // Set OnPCDrop Variable on item's script, if it has a script with that variable declared if (!script.empty()) @@ -2212,7 +2212,7 @@ namespace MWWorld { mWorldScene->addObjectToScene(dropped); } - auto script = dropped.getClass().getScript(dropped); + const auto& script = dropped.getClass().getScript(dropped); if (!script.empty()) { mLocalScripts.add(script, dropped); @@ -2861,14 +2861,12 @@ namespace MWWorld const ESM::Cell* ext = getExterior(name); if (!ext) { - std::string cellName = std::string(name); - size_t comma = cellName.find(','); + size_t comma = name.find(','); if (comma != std::string::npos) { int x, y; - std::from_chars_result xResult = std::from_chars(cellName.data(), cellName.data() + comma, x); - std::from_chars_result yResult - = std::from_chars(cellName.data() + comma + 1, cellName.data() + cellName.size(), y); + std::from_chars_result xResult = std::from_chars(name.data(), name.data() + comma, x); + std::from_chars_result yResult = std::from_chars(name.data() + comma + 1, name.data() + name.size(), y); if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range) throw std::runtime_error("Cell coordinates out of range."); else if (xResult.ec == std::errc{} && yResult.ec == std::errc{}) @@ -3431,7 +3429,7 @@ namespace MWWorld return; } - std::string cellName; + std::string_view cellName; if (!closestMarker.mCell->isExterior()) cellName = closestMarker.mCell->getCell()->mName; diff --git a/apps/openmw_test_suite/mwscript/test_utils.hpp b/apps/openmw_test_suite/mwscript/test_utils.hpp index 07e8fff7cc..e5634ffe3d 100644 --- a/apps/openmw_test_suite/mwscript/test_utils.hpp +++ b/apps/openmw_test_suite/mwscript/test_utils.hpp @@ -144,7 +144,7 @@ namespace class TestInterpreterContext : public Interpreter::Context { LocalVariables mLocals; - std::map> mMembers; + std::map mMembers; public: const ESM::RefId& getTarget() const override { return ESM::RefId::sEmpty; }