Skip to content

Commit

Permalink
Fixed wrong range-based for usage
Browse files Browse the repository at this point in the history
We should use reference instead of a copy
  • Loading branch information
Xottab-DUTY committed Aug 8, 2018
1 parent e06400e commit 9df9a63
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ XRCORE_API void _dump_open_files(int mode)
{
if (mode == 1)
{
for (auto file : g_open_files)
for (const auto& file : g_open_files)
{
Log("----opened files");
if (file._reader != nullptr)
Expand All @@ -145,9 +145,8 @@ XRCORE_API void _dump_open_files(int mode)
else
{
Log("----un-used");
for (auto itr : g_open_files)
for (const auto& file : g_open_files)
{
auto file = itr;
if (file._reader == nullptr)
Msg("[%d] fname:%s", file._used, file._fn.c_str());
}
Expand Down Expand Up @@ -894,7 +893,7 @@ void CLocatorAPI::_destroy()
{
CloseLog();

for (auto it : m_files)
for (auto& it : m_files)
{
auto str = pstr(it.name);
xr_free(str);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ void VisualCallback(IKinematics* tpKinematics)
CGameObject* game_object =
smart_cast<CGameObject*>(static_cast<IGameObject*>(tpKinematics->GetUpdateCallbackParam()));
VERIFY(game_object);
for (auto cb : game_object->visual_callbacks())
for (const auto& cb : game_object->visual_callbacks())
cb(tpKinematics);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/LevelGraphDebugRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ void LevelGraphDebugRender::DrawCovers()
auto& nearest = coverPointCache;
nearest.reserve(1000);
ai().cover_manager().covers().nearest(Device.vCameraPosition, 5.0f, nearest);
for (auto coverPoint : nearest)
for (const auto& coverPoint : nearest)
{
// high cover
Fvector pos = coverPoint->position();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/game_cl_deathmatch_buywnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void game_cl_Deathmatch::SetBuyMenuItems(PRESET_ITEMS* pItems, BOOL OnlyPreset)
pCurBuyMenu->ItemToRuck(pItem->object().cNameSect(), Addons);
}
};
for (auto item : add_ammo)
for (const auto& item : add_ammo)
AdditionalAmmoInserter(item);
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/game_sv_capture_the_artefact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1959,9 +1959,9 @@ void game_sv_CaptureTheArtefact::OnDetachItem(CSE_ActorMP* actor, CSE_Abstract*

if (EventPack.B.count > 2)
u_EventSend(EventPack);
for (auto item : to_destroy)
for (const auto& item : to_destroy)
DestroyGameItem(item);
for (auto item : to_reject)
for (const auto& item : to_reject)
RejectGameItem(item);
};
}
Expand Down

0 comments on commit 9df9a63

Please sign in to comment.