[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Fast determination of userdata type
- From: Shaun <delius@...>
- Date: Mon, 19 Sep 2005 10:11:50 +1000 (EST)
Just wondering if there is any collected wisdom about the fastest/nicest
way of determining the type of userdata passed into a C function (from
For example, assuming I have a function that can accept three different
types of userdata (which are actually C++ objects), how do you generally
go about determining which of the three types it is efficiently?
The most obvious idea seems to be:
if (!lua_getmetatable(L, object))
int ok = lua_rawequal(L, -1, -2);
Not exactly fast. I'm thinking some sort of shim that adds a class
identifier to the start of the userdata would be much faster but will make
my implementation a pain. Any other ideas?