Use static table for parts array, Uses a tonne of memory but improves performance a lot.

This commit is contained in:
Simon Robertshaw 2011-12-09 12:06:22 +00:00
parent 056e811d2f
commit f5a58d14f2

View File

@ -101,7 +101,7 @@ void luacon_open(){
lua_setfield(l, tptPropertiesVersion, "build");
lua_setfield(l, tptProperties, "version");
lua_newtable(l);
/*lua_newtable(l);
tptParts = lua_gettop(l);
lua_newtable(l);
tptPartsMeta = lua_gettop(l);
@ -110,6 +110,26 @@ void luacon_open(){
lua_pushcfunction(l, luacon_partsread);
lua_setfield(l, tptPartsMeta, "__index");
lua_setmetatable(l, tptParts);
lua_setfield(l, tptProperties, "parts");*/
lua_newtable(l);
tptParts = lua_gettop(l);
for(i = 0; i < NPART; i++)
{
int currentPart, currentPartMeta;
lua_newtable(l);
currentPart = lua_gettop(l);
lua_newtable(l);
currentPartMeta = lua_gettop(l);
lua_pushinteger(l, i);
lua_setfield(l, currentPart, "id");
lua_pushcfunction(l, luacon_partwrite);
lua_setfield(l, currentPartMeta, "__newindex");
lua_pushcfunction(l, luacon_partread);
lua_setfield(l, currentPartMeta, "__index");
lua_setmetatable(l, currentPart);
lua_rawseti (l, tptParts, i);
}
lua_setfield(l, tptProperties, "parts");
lua_newtable(l);