lua-users home
lua-l archive

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


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,