mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Performance fix + SAO factorization
Original credits goes to @Rogier-5 * Merge common attributes between LuaEntitySAO & PlayerSAO to UnitSAO * Make some functions const * Improve some lists performance by returning const ref Signed-off-by: Loic Blot <loic.blot@unix-experience.fr>
This commit is contained in:
parent
ec30d49e02
commit
6647939403
8 changed files with 88 additions and 117 deletions
|
@ -137,8 +137,8 @@ int ObjectRef::l_remove(lua_State *L)
|
|||
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
|
||||
return 0;
|
||||
|
||||
UNORDERED_SET<int> child_ids = co->getAttachmentChildIds();
|
||||
UNORDERED_SET<int>::iterator it;
|
||||
const UNORDERED_SET<int> &child_ids = co->getAttachmentChildIds();
|
||||
UNORDERED_SET<int>::const_iterator it;
|
||||
for (it = child_ids.begin(); it != child_ids.end(); ++it) {
|
||||
// Child can be NULL if it was deleted earlier
|
||||
if (ServerActiveObject *child = env->getActiveObject(*it))
|
||||
|
@ -396,8 +396,7 @@ int ObjectRef::l_get_armor_groups(lua_State *L)
|
|||
if (co == NULL)
|
||||
return 0;
|
||||
// Do it
|
||||
ItemGroupList groups = co->getArmorGroups();
|
||||
push_groups(L, groups);
|
||||
push_groups(L, co->getArmorGroups());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue