From 5f084cd98d7b3326b51320455364337539710efd Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 5 Oct 2016 00:13:10 +0200 Subject: Make some maps unordered to improve performance * This permit to improve performance on C++11 builds * use some existing typedefs in tools maps * minor code style changes --- src/script/common/c_content.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/script') diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 19873abc5..6fb9080bc 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -829,20 +829,18 @@ void push_tool_capabilities(lua_State *L, // Create groupcaps table lua_newtable(L); // For each groupcap - for(std::map::const_iterator - i = toolcap.groupcaps.begin(); i != toolcap.groupcaps.end(); i++){ + for (ToolGCMap::const_iterator i = toolcap.groupcaps.begin(); + i != toolcap.groupcaps.end(); i++) { // Create groupcap table lua_newtable(L); const std::string &name = i->first; const ToolGroupCap &groupcap = i->second; // Create subtable "times" lua_newtable(L); - for(std::map::const_iterator - i = groupcap.times.begin(); i != groupcap.times.end(); i++){ - int rating = i->first; - float time = i->second; - lua_pushinteger(L, rating); - lua_pushnumber(L, time); + for (UNORDERED_MAP::const_iterator + i = groupcap.times.begin(); i != groupcap.times.end(); i++) { + lua_pushinteger(L, i->first); + lua_pushnumber(L, i->second); lua_settable(L, -3); } // Set subtable "times" @@ -858,8 +856,8 @@ void push_tool_capabilities(lua_State *L, //Create damage_groups table lua_newtable(L); // For each damage group - for(std::map::const_iterator - i = toolcap.damageGroups.begin(); i != toolcap.damageGroups.end(); i++){ + for (DamageGroup::const_iterator i = toolcap.damageGroups.begin(); + i != toolcap.damageGroups.end(); i++) { // Create damage group table lua_pushinteger(L, i->second); lua_setfield(L, -2, i->first.c_str()); -- cgit v1.2.3