From bc291713c56a2bc27ec10cef52dd3a52a0579c7d Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 30 Jan 2012 18:35:54 +0100 Subject: Fixed some lua_newtable/createtable usage When creating a Lua table, it is possible to specify in advance how many array elements and how many non-array elements this table will contain, to avoid dynamic reallocations while filling the table. This wasn't used optimally by the pushSTLContainer helper methods and some other cases. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira --- src/scripting/lua.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index eb50f168..c7053b3c 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -386,7 +386,7 @@ static int chr_get_inventory(lua_State *s) lua_pushinteger(s, tableIndex); // Create the sub-table (value of the main one) - lua_newtable(s); + lua_createtable(s, 0, 4); int subTableStackPosition = lua_gettop(s); // Stores the item info in it. lua_pushstring(s, "slot"); @@ -458,7 +458,7 @@ static int chr_get_equipment(lua_State *s) lua_pushinteger(s, tableIndex); // Create the sub-table (value of the main one) - lua_newtable(s); + lua_createtable(s, 0, 3); int subTableStackPosition = lua_gettop(s); // Stores the item info in it. lua_pushstring(s, "slot"); -- cgit v1.2.3-70-g09d2