From 4594ba652293e776ccba2184c16502a346f4147a Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sat, 30 Nov 2013 12:11:07 -0500 Subject: Optimize table creation --- src/script/common/c_content.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/script/common') diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 65239ff1f..fd98e9480 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -871,26 +871,13 @@ void read_groups(lua_State *L, int index, /******************************************************************************/ void push_items(lua_State *L, const std::vector &items) { - lua_pushcfunction(L, script_error_handler); - int errorhandler = lua_gettop(L); - // Get the table insert function - lua_getglobal(L, "table"); - lua_getfield(L, -1, "insert"); - int table_insert = lua_gettop(L); // Create and fill table - lua_newtable(L); - int table = lua_gettop(L); - for(u32 i=0; i::const_iterator iter = items.begin(); + for (u32 i = 0; iter != items.end(); iter++) { + LuaItemStack::create(L, *iter); + lua_rawseti(L, -2, ++i); } - lua_remove(L, -2); // Remove insert - lua_remove(L, -2); // Remove table - lua_remove(L, -2); // Remove error handler } /******************************************************************************/ -- cgit v1.2.3