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 --- lcode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 1a371ca9..25623df7 100644 --- a/lcode.c +++ b/lcode.c @@ -544,10 +544,10 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { TValue val; lua_State *L = fs->ls->L; Proto *f = fs->f; - const TValue *idx = luaH_get(fs->ls->h, key); /* query scanner table */ + int aux = luaH_get(fs->ls->h, key, &val); /* query scanner table */ int k, oldsize; - if (ttisinteger(idx)) { /* is there an index there? */ - k = cast_int(ivalue(idx)); + if (aux == HOK && ttisinteger(&val)) { /* is there an index there? */ + k = cast_int(ivalue(&val)); /* correct value? (warning: must distinguish floats from integers!) */ if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && luaV_rawequalobj(&f->k[k], v)) @@ -559,7 +559,7 @@ static int addk (FuncState *fs, TValue *key, TValue *v) { /* numerical value does not need GC barrier; table has no metatable, so it does not need to invalidate cache */ setivalue(&val, k); - luaH_finishset(L, fs->ls->h, key, idx, &val); + luaH_set(L, fs->ls->h, key, &val); luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); setobj(L, &f->k[k], v); -- cgit v1.2.3-55-g6feb