Re: Userdata table keys
- From: Javier Guerra Giraldez <javier@xxxxxxxxxxx>
- To: LuaJIT <luajit@xxxxxxxxxxxxx>
- Date: Sun, 12 Feb 2017 17:09:00 +0000
On 12 February 2017 at 10:58, Las <lasssafin@xxxxxxxxx> wrote:
Thanks, I'm not creating the object often though; I just did newproxy
because I thought it would take less space. But maybe a cdata object will be
smallest?
cdata objecta aren't good as table keys. it's true that newproxy
isn't compiled, but that's irrelevant if it's not called in a loop.
the lightest object would be either a number or a lightuserdata, as
both are just TValues without any object structure underneath, but
newproxy creates a size = 0 userdata, which does include a small
boxing structure. an empty table is just as unique and doesn't create
any array or hash table if kept empty. The basic TValue struct a
little bigger, though.
personally, i'd use an empty table unless i want a custom __gc, then
it would have to be a newproxy(true)
--
Javier
Other related posts: