[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: alternative udata checking
- From: William Ahern <william@...>
- Date: Fri, 2 Dec 2011 12:23:10 -0800
On Fri, Dec 02, 2011 at 05:54:11PM -0200, Luiz Henrique de Figueiredo wrote:
> > Would binding the metatable as an upvalue to the methods of a 'class' not
> > be faster? You could skip the table lookup altogether, just get the
> > metatable from argument 1 and compare it to the upvalue to determine
> > 'class' membership.
> Sure, there are probably many ways to do this. The one implemented in
> lauxlib is just one. Another is to keep a weak-keyed table with all
> the udata created by the module and just indexed that. I haven't tried
> this yet though.
Has anyone tried hacking the VM to allow tagging objects with a
user-definable type? This is rather ugly but would save all the table
I was thinking of this after writing a coroutine scheduler. Coroutines
generate and yield event objects--which specify file decriptors, timeouts,
etc--and the scheduler (and any intermediate resume calls) has to validate
these objects on each yield. There are several optimizations I had in mind,
and the internal tagging method was a last resort. Probably I won't have to
bother with any of them (and of course steps 1 thru 3 are to benchmark,
benchmark, benchmark), but I was just curious.