Creating Lua Table in Blitz, Slowed by Preloading.

BlitzMax Forums/BlitzMax Programming/Creating Lua Table in Blitz, Slowed by Preloading.

Ragz(Posted 2006) [#1]
lua_pushstring(state,"cursor")
lua_newtable(state)
	lua_pushstring(state,"x")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
	lua_pushstring(state,"y")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
	lua_pushstring(state,"button")
	lua_pushnumber(state,0)
	lua_settable(state,-3)
lua_settable(state,LUA_GLOBALSINDEX)


This creates a table:
cursor = { x = 0, y = 0, button = 0 }

This takes very little time on it's own. But I also have a function which I call to preload all the images of a directory in, when this is called, all the images load in fast, no delay, but the creation of the table seems to take longer than a minute. Why is this causing such a slow down?

I would load the images in anyway so I can't see much wrong with loading them all in at the start.


taxlerendiosk(Posted 2006) [#2]
Isn't there an alternative to newtable that lets you specify how many fields you are initially going to use? lua_createtable I think.


Ragz(Posted 2006) [#3]
Hmm I think so, is it faster? Why would the preloading of images cause such a huge slowdown though?

EDIT: Hmph, lua create table should take 3 arguments, [state, narr, nrec], but thu blitz version only takes [state], is this function improperly implemented?

EDIT: Infact, all lua_newtable does it call lua_createtable.


teamonkey(Posted 2006) [#4]
It's probably exactly the same issue as this one here: http://blitzbasic.com/Community/posts.php?topic=61873