From 7b171ea2be0e476d7cdc9300b53ba86a9f694161 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Thu, 2 Jul 2015 23:14:30 -0400 Subject: Fix code style from recent commits and add misc. optimizations --- src/script/common/c_content.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/script/common/c_content.cpp') 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 groups) +void push_groups(lua_State *L, const std::map &groups) { lua_newtable(L); - for (std::map::iterator it = groups.begin(); - it != groups.end(); ++it) { + std::map::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 groups) /******************************************************************************/ void push_items(lua_State *L, const std::vector &items) { - // Create and fill table lua_createtable(L, items.size(), 0); - std::vector::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); } } -- cgit v1.2.3