lua-users home
lua-l archive

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


Hi,

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
one setmetatable.

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.

Kind regards,
Diego