Push "valid" only once
This commit is contained in:
parent
0b0f2e1e35
commit
00dff6d283
|
@ -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…
Reference in New Issue