lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hans Fuchs wrote:
By using this method I see a big performance problem, the function isn't just once compiled when it is defined. It is compiled each time the function is accessed. There for I thought I might use luac and luab_dostring. So I would keep a already compiled version of the script returning my function.

I would appreciate any comments or feedback. There are may be way better or simplier methods.

Another method is to load your function with load_string and keep a ref on it, so when you need to get it you just need to claim the ref, so no compile needed.

Some questions:

Would using the precompiled script reach almost the same perfomance as a normaly defined function?

The lua compiler is very fast so no big difference in most case.

Is anything to say against the trick using "return function()"?

Have I missed any problems?

Do you know a better method way?

Any better methods?

You van also keep an other global table with accessible data and function and store it in the lua registry so when your index was call you first check if the user have the right and if you just get the table and retrieve the corresponding data.




Thomas Lavergne                       "Le vrai rêveur est celui qui rêve
                                       de l'impossible."  (Elsa Triolet)    ICQ:#137121910