Key lookup optimizations...

  • From: Lance Thornblad <lance.thornblad@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 1 Sep 2015 12:39:51 -0600

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.

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

Other related posts: