lua-users home
lua-l archive

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

On Sep 9, 2013, at 10:58 PM, Miles Bader <> wrote:

>> If you use lightuserdata there's no namespacing conflict, assuming a flat
>> process address space. Just take the address of a function, or if casting
>> function pointers to void pointers is distasteful, define a static const
>> variable and use its address.
> Hmm, then you presumably don't get the same speed advantage as small
> integers, right?  I guess hashing a lightuserdata might be faster than
> hashing a string, although I dunno how much for short strings...
> -miles
> -- 
> 97% of everything is grunge

… and that was the problem I faced as well. To be able to translate from Lua_State* -> Private_State* would mean using Lua_State* as a light userdata into the Registry, which is slower than integer access. Of course, any mechanism to do Lua_State* -> Integer -> Private_State* via the registry is pointless, because you might as well do Lua_State* -> Private_State* by the same mechanism.

Interesting that you found upvalues faster .. I didn't test these as I'd figured out the custom allocator trick by that point and I doubt if an upvalue would be as fast.