From 0593256707ceddb1bc9cd4b25b822a7fbcfedd66 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 21 Mar 2024 11:23:21 -0300 Subject: 'luaH_get' functions return tag of the result Undoing previous commit. Returning TValue increases code size without any visible gains. Returning the tag is a little simpler than returning a special code (HOK/HNOTFOUND) and the tag is useful by itself in some cases. --- lcode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 18bf9413..2c57fdaf 100644 --- a/lcode.c +++ b/lcode.c @@ -541,11 +541,12 @@ static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { ** a function can make some indices wrong. */ static int addk (FuncState *fs, TValue *key, TValue *v) { + TValue val; lua_State *L = fs->ls->L; Proto *f = fs->f; - TValue val = luaH_get(fs->ls->h, key); /* query scanner table */ + int tag = luaH_get(fs->ls->h, key, &val); /* query scanner table */ int k, oldsize; - if (ttisintegerV(val)) { /* is there an index there? */ + if (tag == LUA_VNUMINT) { /* 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) && -- cgit v1.2.3-55-g6feb