aboutsummaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-05 00:13:10 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-05 07:30:32 +0200
commit5f084cd98d7b3326b51320455364337539710efd (patch)
treed66681421b1b1dfa18d1feb3f0a66d5c03e00c86 /src/script/common
parentd4c76258e37337ea585cf24d8e05b50a30fa307d (diff)
downloadminetest-5f084cd98d7b3326b51320455364337539710efd.tar.gz
minetest-5f084cd98d7b3326b51320455364337539710efd.tar.bz2
minetest-5f084cd98d7b3326b51320455364337539710efd.zip
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
Diffstat (limited to 'src/script/common')
-rw-r--r--src/script/common/c_content.cpp18
1 files changed, 8 insertions, 10 deletions
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<std::string, ToolGroupCap>::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<int, float>::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<int, float>::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<std::string, s16>::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());