[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI: pointer<->lightuserdata ?
- From: Mike Pall <mikelu-1102@...>
- Date: Wed, 16 Feb 2011 14:35:45 +0100
Javier Guerra Giraldez wrote:
> but a common
> idiom i've used before is to take a C pointer, make it into a
> lightuserdata and use as a table key. the suggested workaround is to
> use tonumber(); why not cast into a lightuserdata?
There's no difference in efficiency between a 52 bit number and a
32 or 47 bit lightuserdata, when using them as table keys. The
hash algorithm is the same.
[This advice is valid for LuaJIT, only.]
> in the FFI reference, the lightuserdata->(void *) conversion is
> automatic; but i don't see how to do the converse.
Well, nobody asked for it. :-)
> am i missing some downside of a (void *)->lightuserdata conversion?
Lightuserdata is generally only needed for the classic Lua/C API,
so it would be a bit backwards to suggest its use for new stuff.
--Mike