mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Optimize lua_touserdata by checking userdata case first
This commit is contained in:
parent
fcbc012568
commit
22e57a8eab
1 changed files with 4 additions and 6 deletions
|
@ -487,15 +487,13 @@ void* lua_tolightuserdata(lua_State* L, int idx)
|
|||
void* lua_touserdata(lua_State* L, int idx)
|
||||
{
|
||||
StkId o = index2addr(L, idx);
|
||||
switch (ttype(o))
|
||||
{
|
||||
case LUA_TUSERDATA:
|
||||
// fast-path: check userdata first since it is most likely the expected result
|
||||
if (ttisuserdata(o))
|
||||
return uvalue(o)->data;
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
else if (ttislightuserdata(o))
|
||||
return pvalue(o);
|
||||
default:
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void* lua_touserdatatagged(lua_State* L, int idx, int tag)
|
||||
|
|
Loading…
Add table
Reference in a new issue