On 01/09/15 03:39 PM, Lance Thornblad wrote:
I'm using LuaJIT with my game engine, and am wondering how hash table optimizations are done (?). Game objects are exposed as userdata and the member lookup is done using a hidden table with a C function as its __index metamethod, as is typically done.I don't think LuaJIT has an API to handle JITting.
Since my C function does its own hash lookup, it occurs to me that I am probably losing the benefit of optimization. When LuaJIT interprets "foo.bar," for example, how is the "bar" part handled on subsequent uses? I assume the hash lookup doesn't have to happen every time that code is called.
Is there any way you know that I can call my C function once, but replace it with something faster for subsequent calls?
Hope that makes sense...
Lance