diff options
author | Rogier <rogier777@gmail.com> | 2017-01-10 04:39:45 +0900 |
---|---|---|
committer | Ner'zhul <nerzhul@users.noreply.github.com> | 2017-01-11 15:53:56 +0100 |
commit | 66479394037baa941cb06d75d3afc79ff4c717a2 (patch) | |
tree | ade7d34a6c37987ebbd227df422c5643473194e8 /src/script | |
parent | ec30d49e026af2d0cb8329eb66aec48d12e79839 (diff) | |
download | minetest-66479394037baa941cb06d75d3afc79ff4c717a2.tar.gz minetest-66479394037baa941cb06d75d3afc79ff4c717a2.tar.bz2 minetest-66479394037baa941cb06d75d3afc79ff4c717a2.zip |
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>
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index cfdceb28e..84d14d521 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -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; } |