On Sat, Sep 19, 2009 at 5:16 PM, zweifel <email@example.com> wrote:If you want to run a script multiple times, then load it once
> hmm, these are a good solution when I just want to run the script once.
> But in my case I do want to run the Lua script every frame. I just wanted to
> know if I should bother with a hash_table and luaL_loadbuffer or just use
> luaL_dofile because Lua already does some caching of files that was already
> read before.
(lua_load, luaL_loadbuffer, luaL_loadfile, etc.), save the result (a
Lua function) somewhere, and then run it (lua_call / lua_pcall)
multiple times. You should assume that reading a file is expensive,
and that the parsing done by lua_load (and other load functions which
all call lua_load) is also expensive - avoid calling any load function
per frame, and avoid even more load functions which read files.