diff --git a/zone/lua_entity_list.cpp b/zone/lua_entity_list.cpp index 1a334fc99..a90b9966b 100644 --- a/zone/lua_entity_list.cpp +++ b/zone/lua_entity_list.cpp @@ -641,9 +641,7 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob) { Lua_Mob_List ret; const auto& l = self->GetCloseMobList(mob); - ret.entries.reserve(l.size()); - for (const auto& e : l) { ret.entries.emplace_back(Lua_Mob(e.second)); } @@ -653,14 +651,9 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob) { Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob, float distance) { Lua_Safe_Call_Class(Lua_Mob_List); - Lua_Mob_List ret; - const auto& l = self->GetCloseMobList(mob); - - ret.entries.reserve(l.size()); - - for (const auto& e : l) { + for (const auto& e : self->GetCloseMobList(mob)) { if (mob.CalculateDistance(e.second) <= distance) { ret.entries.emplace_back(Lua_Mob(e.second)); } @@ -674,11 +667,7 @@ Lua_Mob_List Lua_EntityList::GetCloseMobList(Lua_Mob mob, float distance, bool i Lua_Mob_List ret; - const auto& l = self->GetCloseMobList(mob); - - ret.entries.reserve(l.size()); - - for (const auto& e : l) { + for (const auto& e : self->GetCloseMobList(mob)) { if (ignore_self && e.second == mob) { continue; } diff --git a/zone/perl_entity.cpp b/zone/perl_entity.cpp index 025f1d7d2..42baee9f8 100644 --- a/zone/perl_entity.cpp +++ b/zone/perl_entity.cpp @@ -614,11 +614,8 @@ Bot* Perl_EntityList_GetRandomBot(EntityList* self, float x, float y, float z, f perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob) { perl::array result; - const auto& l = self->GetCloseMobList(mob); - result.reserve(l.size()); - for (const auto& e : l) { result.push_back(e.second); } @@ -629,12 +626,7 @@ perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob) perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float distance) { perl::array result; - - const auto& l = self->GetCloseMobList(mob, distance); - - result.reserve(l.size()); - - for (const auto& e : l) { + for (const auto& e : self->GetCloseMobList(mob, distance)) { if (mob->CalculateDistance(e.second) <= distance) { result.push_back(e.second); } @@ -646,12 +638,7 @@ perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float di perl::array Perl_EntityList_GetCloseMobList(EntityList* self, Mob* mob, float distance, bool ignore_self) { perl::array result; - - const auto& l = self->GetCloseMobList(mob, distance); - - result.reserve(l.size()); - - for (const auto& e : l) { + for (const auto& e : self->GetCloseMobList(mob, distance)) { if (ignore_self && e.second == mob) { continue; }