mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-03 15:32:45 +00:00
Push "valid" only once
This commit is contained in:
parent
a4ea83b1dc
commit
20c6259821
1 changed files with 7 additions and 1 deletions
|
|
@ -167,7 +167,7 @@ static void push_taglist(lua_State *L, int idx)
|
||||||
static int has_valid_field(lua_State *L)
|
static int has_valid_field(lua_State *L)
|
||||||
{
|
{
|
||||||
int equal;
|
int equal;
|
||||||
lua_pushliteral(L, "valid");
|
lua_rawgeti(L, LUA_ENVIRONINDEX, 1);
|
||||||
equal = lua_rawequal(L, 2, -1);
|
equal = lua_rawequal(L, 2, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return equal;
|
return equal;
|
||||||
|
|
@ -392,6 +392,9 @@ static void open_taglist(lua_State *L)
|
||||||
lua_setfield(L, -2, "has");
|
lua_setfield(L, -2, "has");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define new_literal(L, s) \
|
||||||
|
(lua_pushliteral(L, s), luaL_ref(L, -2))
|
||||||
|
|
||||||
static void set_taglist_metatable(lua_State *L, const char *meta)
|
static void set_taglist_metatable(lua_State *L, const char *meta)
|
||||||
{
|
{
|
||||||
lua_createtable(L, 0, 4);
|
lua_createtable(L, 0, 4);
|
||||||
|
|
@ -399,6 +402,9 @@ static void set_taglist_metatable(lua_State *L, const char *meta)
|
||||||
lua_setfield(L, -2, "taglist");
|
lua_setfield(L, -2, "taglist");
|
||||||
|
|
||||||
lua_pushcfunction(L, taglist_get);
|
lua_pushcfunction(L, taglist_get);
|
||||||
|
lua_createtable(L, 0, 1);
|
||||||
|
new_literal(L, "valid");
|
||||||
|
lua_setfenv(L, -2);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
lua_pushcfunction(L, taglist_len);
|
lua_pushcfunction(L, taglist_len);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue