summaryrefslogtreecommitdiff
path: root/src/script/common/c_content.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-07-02 23:14:30 -0400
committerkwolekr <kwolekr@minetest.net>2015-07-02 23:14:30 -0400
commit7b171ea2be0e476d7cdc9300b53ba86a9f694161 (patch)
treede1768db2a4dce40738ed96248f29f7c923c527b /src/script/common/c_content.cpp
parent0a0378fecef5c6b4be6d034d8bced2a1568dde81 (diff)
downloadminetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.tar.gz
minetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.tar.bz2
minetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.zip
Fix code style from recent commits and add misc. optimizations
Diffstat (limited to 'src/script/common/c_content.cpp')
-rw-r--r--src/script/common/c_content.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 94fcdecbb..4db92190b 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -985,11 +985,11 @@ void read_groups(lua_State *L, int index,
}
/******************************************************************************/
-void push_groups(lua_State *L, std::map<std::string, int> groups)
+void push_groups(lua_State *L, const std::map<std::string, int> &groups)
{
lua_newtable(L);
- for (std::map<std::string, int>::iterator it = groups.begin();
- it != groups.end(); ++it) {
+ std::map<std::string, int>::const_iterator it;
+ for (it = groups.begin(); it != groups.end(); ++it) {
lua_pushnumber(L, it->second);
lua_setfield(L, -2, it->first.c_str());
}
@@ -998,12 +998,10 @@ void push_groups(lua_State *L, std::map<std::string, int> groups)
/******************************************************************************/
void push_items(lua_State *L, const std::vector<ItemStack> &items)
{
- // Create and fill table
lua_createtable(L, items.size(), 0);
- std::vector<ItemStack>::const_iterator iter = items.begin();
- for (u32 i = 0; iter != items.end(); iter++) {
- LuaItemStack::create(L, *iter);
- lua_rawseti(L, -2, ++i);
+ for (u32 i = 0; i != items.size(); i++) {
+ LuaItemStack::create(L, items[i]);
+ lua_rawseti(L, -2, i + 1);
}
}