From 7deb6a6ffd3e46a58441ac6fa94a538447e90ea5 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 15 May 2021 19:50:01 +0200 Subject: [PATCH] Use const references when possible in for loops No need for useless copies. --- apps/openmw/mwgui/dialogue.cpp | 2 +- apps/openmw/mwmechanics/spelllist.cpp | 2 +- apps/openmw/mwrender/objectpaging.cpp | 4 ++-- apps/openmw/mwworld/esmstore.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 1f155bd47..0fda54eba 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -306,7 +306,7 @@ namespace MWGui deleteLater(); for (Link* link : mLinks) delete link; - for (auto link : mTopicLinks) + for (const auto& link : mTopicLinks) delete link.second; for (auto history : mHistoryContents) delete history; diff --git a/apps/openmw/mwmechanics/spelllist.cpp b/apps/openmw/mwmechanics/spelllist.cpp index 24a04788e..9328d533e 100644 --- a/apps/openmw/mwmechanics/spelllist.cpp +++ b/apps/openmw/mwmechanics/spelllist.cpp @@ -70,7 +70,7 @@ namespace MWMechanics auto& id = spell->mId; bool changed = withBaseRecord([&] (auto& spells) { - for(auto it : spells) + for(const auto& it : spells) { if(Misc::StringUtils::ciEqual(id, it)) return false; diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index 4217c4714..174c25959 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -743,7 +743,7 @@ namespace MWRender ccf.mCell = cell; mCache->call(ccf); if (ccf.mToClear.empty()) return false; - for (auto chunk : ccf.mToClear) + for (const auto& chunk : ccf.mToClear) mCache->removeFromObjectCache(chunk); return true; } @@ -765,7 +765,7 @@ namespace MWRender ccf.mActiveGridOnly = true; mCache->call(ccf); if (ccf.mToClear.empty()) return false; - for (auto chunk : ccf.mToClear) + for (const auto& chunk : ccf.mToClear) mCache->removeFromObjectCache(chunk); return true; } diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index a69d74b05..0ec6d8d73 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -63,7 +63,7 @@ namespace // We will replace invalid entries by fixed ones std::vector npcsToReplace; - for (auto npcIter : npcs) + for (const auto& npcIter : npcs) { ESM::NPC npc = npcIter.second; bool changed = false;