diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-21 11:23:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-21 11:23:21 -0300 |
commit | 0593256707ceddb1bc9cd4b25b822a7fbcfedd66 (patch) | |
tree | 6c6859b94086b71b27409b565ed34c114f03e7f8 /lcode.c | |
parent | ce6f5502c99ce9a367e25b678e375db6f8164d73 (diff) | |
download | lua-0593256707ceddb1bc9cd4b25b822a7fbcfedd66.tar.gz lua-0593256707ceddb1bc9cd4b25b822a7fbcfedd66.tar.bz2 lua-0593256707ceddb1bc9cd4b25b822a7fbcfedd66.zip |
'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.
Diffstat (limited to '')
-rw-r--r-- | lcode.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -541,11 +541,12 @@ static void freeexps (FuncState *fs, expdesc *e1, expdesc *e2) { | |||
541 | ** a function can make some indices wrong. | 541 | ** a function can make some indices wrong. |
542 | */ | 542 | */ |
543 | static int addk (FuncState *fs, TValue *key, TValue *v) { | 543 | static int addk (FuncState *fs, TValue *key, TValue *v) { |
544 | TValue val; | ||
544 | lua_State *L = fs->ls->L; | 545 | lua_State *L = fs->ls->L; |
545 | Proto *f = fs->f; | 546 | Proto *f = fs->f; |
546 | TValue val = luaH_get(fs->ls->h, key); /* query scanner table */ | 547 | int tag = luaH_get(fs->ls->h, key, &val); /* query scanner table */ |
547 | int k, oldsize; | 548 | int k, oldsize; |
548 | if (ttisintegerV(val)) { /* is there an index there? */ | 549 | if (tag == LUA_VNUMINT) { /* is there an index there? */ |
549 | k = cast_int(ivalue(&val)); | 550 | k = cast_int(ivalue(&val)); |
550 | /* correct value? (warning: must distinguish floats from integers!) */ | 551 | /* correct value? (warning: must distinguish floats from integers!) */ |
551 | if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && | 552 | if (k < fs->nk && ttypetag(&f->k[k]) == ttypetag(v) && |