love get* APIs which return tables with fields can optionally accept a table argument to fill in, instead of creating a new table.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-09-22 19:47:55 -03:00
parent a2ad1b462f
commit 4ee85e1793
5 changed files with 48 additions and 16 deletions
+4 -1
View File
@@ -371,7 +371,10 @@ int w_getInfo(lua_State *L)
if (!Filesystem::getConstant(info.type, typestr))
return luaL_error(L, "Unknown file type.");
lua_createtable(L, 0, 3);
if (lua_istable(L, 2))
lua_pushvalue(L, 2);
else
lua_createtable(L, 0, 3);
lua_pushstring(L, typestr);
lua_setfield(L, -2, "type");