[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A proposal for faster userdata type checking
- From: Diego Nehab <diego@...>
- Date: Fri, 29 Feb 2008 03:49:19 -0500 (EST)
Hi,
As the Mike's example shows, if you are willing to be a
little less generic, you can store the metatable as an
upvalue or as the enviromnent for each function that must do
type checking for that class. That way, you save one rawget
during the checkudata call, which is by far the most common
case. I might do that, and offer two versions of checkudata.
The generic one taking the lightuserdata, and obtains the
metatable from it. The optimized one takes no extra
argument, and assumes instead that the expected metatable is
the environment.
Kind regards,
Diego