diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-04-25 10:17:53 +0200 |
---|---|---|
committer | Loïc Blot <loic.blot@unix-experience.fr> | 2017-04-25 10:21:42 +0200 |
commit | a7e131f53e211ffbe38d34d23b33e13cc401f013 (patch) | |
tree | c615160a94df851752d62bfc2a4cf9f4d01f63ab /src/script/lua_api | |
parent | af9630962134346750f12c9f1856eae00e0dfe02 (diff) | |
download | minetest-a7e131f53e211ffbe38d34d23b33e13cc401f013.tar.gz minetest-a7e131f53e211ffbe38d34d23b33e13cc401f013.tar.bz2 minetest-a7e131f53e211ffbe38d34d23b33e13cc401f013.zip |
Fix various points reported by cppcheck (#5656)
* Fix various performance issues reported by cppcheck + code style (CI)
* Make CI happy with code style on master
* guiFileSelectMenu: remove useless includes
* some performance fixes pointed by cppcheck
* remove some useless casts
* TextDest: remove unused setFormSpec function
* Fix various iterator post-increment reported by cppcheck
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_client.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_craft.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_env.cpp | 5 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_nodemeta.cpp | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_server.cpp | 4 |
6 files changed, 8 insertions, 9 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index be3a749de..09ea5506b 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -83,7 +83,7 @@ int ModApiClient::l_get_player_names(lua_State *L) int newTable = lua_gettop(L); int index = 1; std::list<std::string>::const_iterator iter; - for (iter = plist.begin(); iter != plist.end(); iter++) { + for (iter = plist.begin(); iter != plist.end(); ++iter) { lua_pushstring(L, (*iter).c_str()); lua_rawseti(L, newTable, index); index++; diff --git a/src/script/lua_api/l_craft.cpp b/src/script/lua_api/l_craft.cpp index 2236566de..315391856 100644 --- a/src/script/lua_api/l_craft.cpp +++ b/src/script/lua_api/l_craft.cpp @@ -414,7 +414,7 @@ static void push_craft_recipe(lua_State *L, IGameDef *gdef, lua_newtable(L); // items std::vector<ItemStack>::const_iterator iter = input.items.begin(); - for (u16 j = 1; iter != input.items.end(); iter++, j++) { + for (u16 j = 1; iter != input.items.end(); ++iter, j++) { if (iter->empty()) continue; lua_pushstring(L, iter->name.c_str()); diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 1fa7845b5..75b07fa37 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -534,7 +534,7 @@ int ModApiEnvMod::l_get_objects_inside_radius(lua_State *L) ScriptApiBase *script = getScriptApiBase(L); lua_createtable(L, ids.size(), 0); std::vector<u16>::const_iterator iter = ids.begin(); - for(u32 i = 0; iter != ids.end(); iter++) { + for(u32 i = 0; iter != ids.end(); ++iter) { ServerActiveObject *obj = env->getActiveObject(*iter); // Insert object reference into table script->objectrefGetOrCreate(L, obj); @@ -985,8 +985,7 @@ int ModApiEnvMod::l_find_path(lua_State *L) lua_newtable(L); int top = lua_gettop(L); unsigned int index = 1; - for (std::vector<v3s16>::iterator i = path.begin(); i != path.end();i++) - { + for (std::vector<v3s16>::iterator i = path.begin(); i != path.end(); ++i) { lua_pushnumber(L,index); push_v3s16(L, *i); lua_settable(L, top); diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 3d204db98..4d0be257c 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -297,7 +297,7 @@ int ModApiMainMenu::l_get_games(lua_State *L) int table2 = lua_gettop(L); int internal_index=1; for (std::set<std::string>::iterator iter = games[i].addon_mods_paths.begin(); - iter != games[i].addon_mods_paths.end(); iter++) { + iter != games[i].addon_mods_paths.end(); ++iter) { lua_pushnumber(L,internal_index); lua_pushstring(L,(*iter).c_str()); lua_settable(L, table2); diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp index c65d56f14..6232112c5 100644 --- a/src/script/lua_api/l_nodemeta.cpp +++ b/src/script/lua_api/l_nodemeta.cpp @@ -107,7 +107,7 @@ void NodeMetaRef::handleToTable(lua_State *L, Metadata *_meta) if (inv) { std::vector<const InventoryList *> lists = inv->getLists(); for(std::vector<const InventoryList *>::const_iterator - i = lists.begin(); i != lists.end(); i++) { + i = lists.begin(); i != lists.end(); ++i) { push_inventory_list(L, inv, (*i)->getName().c_str()); lua_setfield(L, -2, (*i)->getName().c_str()); } diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp index d94f3e31d..813d5a945 100644 --- a/src/script/lua_api/l_server.cpp +++ b/src/script/lua_api/l_server.cpp @@ -103,7 +103,7 @@ int ModApiServer::l_get_player_privs(lua_State *L) int table = lua_gettop(L); std::set<std::string> privs_s = server->getPlayerEffectivePrivs(name); for(std::set<std::string>::const_iterator - i = privs_s.begin(); i != privs_s.end(); i++){ + i = privs_s.begin(); i != privs_s.end(); ++i){ lua_pushboolean(L, true); lua_setfield(L, table, i->c_str()); } @@ -417,7 +417,7 @@ int ModApiServer::l_get_modnames(lua_State *L) // Package them up for Lua lua_createtable(L, modlist.size(), 0); std::vector<std::string>::iterator iter = modlist.begin(); - for (u16 i = 0; iter != modlist.end(); iter++) { + for (u16 i = 0; iter != modlist.end(); ++iter) { lua_pushstring(L, iter->c_str()); lua_rawseti(L, -2, ++i); } |