Skip to content

Commit 9df9a63

Browse files
committed
Fixed wrong range-based for usage
We should use reference instead of a copy
1 parent e06400e commit 9df9a63

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/xrCore/LocatorAPI.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ XRCORE_API void _dump_open_files(int mode)
135135
{
136136
if (mode == 1)
137137
{
138-
for (auto file : g_open_files)
138+
for (const auto& file : g_open_files)
139139
{
140140
Log("----opened files");
141141
if (file._reader != nullptr)
@@ -145,9 +145,8 @@ XRCORE_API void _dump_open_files(int mode)
145145
else
146146
{
147147
Log("----un-used");
148-
for (auto itr : g_open_files)
148+
for (const auto& file : g_open_files)
149149
{
150-
auto file = itr;
151150
if (file._reader == nullptr)
152151
Msg("[%d] fname:%s", file._used, file._fn.c_str());
153152
}
@@ -894,7 +893,7 @@ void CLocatorAPI::_destroy()
894893
{
895894
CloseLog();
896895

897-
for (auto it : m_files)
896+
for (auto& it : m_files)
898897
{
899898
auto str = pstr(it.name);
900899
xr_free(str);

src/xrGame/GameObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ void VisualCallback(IKinematics* tpKinematics)
11411141
CGameObject* game_object =
11421142
smart_cast<CGameObject*>(static_cast<IGameObject*>(tpKinematics->GetUpdateCallbackParam()));
11431143
VERIFY(game_object);
1144-
for (auto cb : game_object->visual_callbacks())
1144+
for (const auto& cb : game_object->visual_callbacks())
11451145
cb(tpKinematics);
11461146
}
11471147

src/xrGame/LevelGraphDebugRender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ void LevelGraphDebugRender::DrawCovers()
737737
auto& nearest = coverPointCache;
738738
nearest.reserve(1000);
739739
ai().cover_manager().covers().nearest(Device.vCameraPosition, 5.0f, nearest);
740-
for (auto coverPoint : nearest)
740+
for (const auto& coverPoint : nearest)
741741
{
742742
// high cover
743743
Fvector pos = coverPoint->position();

src/xrGame/game_cl_deathmatch_buywnd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void game_cl_Deathmatch::SetBuyMenuItems(PRESET_ITEMS* pItems, BOOL OnlyPreset)
244244
pCurBuyMenu->ItemToRuck(pItem->object().cNameSect(), Addons);
245245
}
246246
};
247-
for (auto item : add_ammo)
247+
for (const auto& item : add_ammo)
248248
AdditionalAmmoInserter(item);
249249
}
250250
else

src/xrGame/game_sv_capture_the_artefact.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,9 +1959,9 @@ void game_sv_CaptureTheArtefact::OnDetachItem(CSE_ActorMP* actor, CSE_Abstract*
19591959

19601960
if (EventPack.B.count > 2)
19611961
u_EventSend(EventPack);
1962-
for (auto item : to_destroy)
1962+
for (const auto& item : to_destroy)
19631963
DestroyGameItem(item);
1964-
for (auto item : to_reject)
1964+
for (const auto& item : to_reject)
19651965
RejectGameItem(item);
19661966
};
19671967
}

0 commit comments

Comments
 (0)