From 819bd51d87b799fdee029754c660dc9a5587ef57 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 May 2023 16:53:29 -0300 Subject: Some cleaning in the new table API --- llex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llex.c') diff --git a/llex.c b/llex.c index 5fc39a5c..9f20d3c8 100644 --- a/llex.c +++ b/llex.c @@ -134,13 +134,13 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) { TString *luaX_newstring (LexState *ls, const char *str, size_t l) { lua_State *L = ls->L; TString *ts = luaS_newlstr(L, str, l); /* create new string */ - const TValue *o = luaH_getstr(ls->h, ts); - if (!ttisnil(o)) /* string already present? */ - ts = keystrval(nodefromval(o)); /* get saved copy */ - else { /* not in use yet */ + TString *oldts = luaH_getstrkey(ls->h, ts); + if (oldts != NULL) /* string already present? */ + return oldts; /* use it */ + else { /* create a new entry */ TValue *stv = s2v(L->top.p++); /* reserve stack space for string */ setsvalue(L, stv, ts); /* temporarily anchor the string */ - luaH_finishset(L, ls->h, stv, o, stv); /* t[string] = string */ + luaH_set(L, ls->h, stv, stv); /* t[string] = string */ /* table is not a metatable, so it does not need to invalidate cache */ luaC_checkGC(L); L->top.p--; /* remove string from stack */ -- cgit v1.2.3-55-g6feb