lua-users home
lua-l archive

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


> On 15/01/2013 4:22 PM, Hadriel Kaplan wrote:
> >For example, if you use luaL_ref() with the Registry to provide a
> >unique reference to a created userdata to avoid creating multiples,
> >by storing that reference integer in the C++ object, then you can use
> >that instead of the raw userdata address to find it again from the
> >Registry.  The C++ object's destructor would use it to find the
> >userdata from the Registry, clear its own pointer from within the
> >userdata, and remove the reference from the Registry (luaL_unref).
> >It sounds like that might work(?)
> 
> I could be wrong but I think this involves a hash table lookup every
> time you want to construct or invalidate a pointer. That's a valid
> approach but it's nowhere near as as efficient as the counter method
> we started with.

Did you benchmark this? I mean, is the extra table lookup relevant
against the cost of creating/invalidating references?

-- Roberto