1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-22 21:40:42 +00:00

Use const references when possible in for loops

No need for useless copies.
This commit is contained in:
jvoisin 2021-05-15 19:50:01 +02:00
parent 8a315b01ae
commit 7deb6a6ffd
4 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -63,7 +63,7 @@ namespace
// We will replace invalid entries by fixed ones
std::vector<ESM::NPC> npcsToReplace;
for (auto npcIter : npcs)
for (const auto& npcIter : npcs)
{
ESM::NPC npc = npcIter.second;
bool changed = false;