lua-users home
lua-l archive

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

> This is a continuation of my luaL_checkudata/luaL_testudata
> optimization ideas. How about a new API, lua_metatabletopointer (or
> lua_getmetatablepointer?), acting as if lua_getmetatable followed by
> lua_topointer, but without touching the Lua stack? This would enable
> faster "are we really called with 'our' userdata?" checks and reduce
> userdata metamethod call overhead (checks would trivially extend to,
> say, a list of metatables known to a function).

I think the main issue here is what to compare the metatable with,
that is, how to specify which metatable we want. Your suggestion of
comparing the metatable against a given upvalue is interesting, but
it clashes with light C functions. (Most C functions using userdata
would need to be heavy.)

Another idea would be to write 'luaL_testudata' inside the kernel,
to avoid all stack manipulation and other API overheads. We would
need to test first to know how much could we gain with that.

-- Roberto