[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A proposal for faster userdata type checking
- From: Diego Nehab <diego@...>
- Date: Thu, 28 Feb 2008 19:43:20 -0500 (EST)
Sure. I don't have the code on me right now. The main
ideas is this:
Avoid the strings as class names. Use lightuserdata
instead. The key contains the addresses of the strings, not
the values of the strings. The strings are extern const
strings defined in whatever module created the class, and
exported in its .h file.
So to set a userdata to a class, you only need one rawget,
using a lightuserdata as key, from the class table (which
can be the registry or a private table in an upvalue), plus
To check a userdata you need one touserdata, that one rawget,
one getmetatable, and one isequal.
The savings come from the fact you don't traverse strings,
ever, and you don't create strings, ever.