fix(Core/ObjectGuid): prevent creating copies when looping objects (#6852)

This commit is contained in:
Francesco Borzì
2021-07-10 15:54:16 +02:00
committed by GitHub
parent 2fcafa5f39
commit 4103fca5a4
40 changed files with 69 additions and 69 deletions

View File

@@ -265,7 +265,7 @@ void PetAI::UpdateAI(uint32 diff)
// No enemy, check friendly
if (!spellUsed)
{
for (ObjectGuid const guid : m_AllySet)
for (ObjectGuid const& guid : m_AllySet)
{
Unit* ally = ObjectAccessor::GetUnit(*me, guid);

View File

@@ -328,7 +328,7 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
{
Creature* sh = nullptr;
for (ObjectGuid const guid : itr->second)
for (ObjectGuid const& guid : itr->second)
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
@@ -360,7 +360,7 @@ inline void Battleground::_ProcessResurrect(uint32 diff)
}
else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
{
for (ObjectGuid const guid : m_ResurrectQueue)
for (ObjectGuid const& guid : m_ResurrectQueue)
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)
@@ -1479,7 +1479,7 @@ void Battleground::RelocateDeadPlayers(ObjectGuid queueIndex)
if (!ghostList.empty())
{
GraveyardStruct const* closestGrave = nullptr;
for (ObjectGuid const guid : ghostList)
for (ObjectGuid const& guid : ghostList)
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)

View File

@@ -897,7 +897,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source)
if (!ghost_list.empty())
{
GraveyardStruct const* ClosestGrave = nullptr;
for (ObjectGuid const guid : ghost_list)
for (ObjectGuid const& guid : ghost_list)
{
Player* player = ObjectAccessor::FindPlayer(guid);
if (!player)

View File

@@ -1129,7 +1129,7 @@ namespace lfg
if (!deletedGroupsToErase.empty())
{
for (ObjectGuid const toErase : deletedGroupsToErase)
for (ObjectGuid const& toErase : deletedGroupsToErase)
{
deletedGroups.erase(toErase);
}
@@ -1137,7 +1137,7 @@ namespace lfg
if (!deletedGroups.empty())
{
for (ObjectGuid const deletedGroup : deletedGroups)
for (ObjectGuid const& deletedGroup : deletedGroups)
{
++deletedCounter;
buffer_deleted << deletedGroup;

View File

@@ -212,7 +212,7 @@ void GameObject::ClearRitualList()
if (!animSpell || m_unique_users.empty())
return;
for (ObjectGuid const guid : m_unique_users)
for (ObjectGuid const& guid : m_unique_users)
{
if (Player* channeler = ObjectAccessor::GetPlayer(*this, guid))
if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))

View File

@@ -843,7 +843,7 @@ public:
void AddToSkillupList(ObjectGuid playerGuid) { m_SkillupList.push_back(playerGuid); }
[[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const
{
for (ObjectGuid const guid : m_SkillupList)
for (ObjectGuid const& guid : m_SkillupList)
if (guid == playerGuid)
return true;

View File

@@ -104,7 +104,7 @@ bool UpdateData::BuildPacket(WorldPacket* packet)
buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS;
buf << (uint32) m_outOfRangeGUIDs.size();
for (ObjectGuid const guid : m_outOfRangeGUIDs)
for (ObjectGuid const& guid : m_outOfRangeGUIDs)
{
buf << guid.WriteAsPacked();
}

View File

@@ -784,7 +784,7 @@ void PoolMgr::LoadFromDB()
// Now check for circular reference
// All pool_ids are in pool_template
for (auto const it : mPoolTemplate)
for (auto const& it : mPoolTemplate)
{
std::set<uint32> checkedPools;
for (SearchMap::iterator poolItr = mPoolSearchMap.find(it.first); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second))