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. --- lvm.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'lvm.h') diff --git a/lvm.h b/lvm.h index 3b11e789..a11db83c 100644 --- a/lvm.h +++ b/lvm.h @@ -78,19 +78,17 @@ typedef enum { /* ** fast track for 'gettable' */ -#define luaV_fastget(t,k,res,f, aux) \ - {if (!ttistable(t)) setnotableV(aux); \ - else { aux = f(hvalue(t), k); \ - if (!isemptyV(aux)) { setobjV(cast(lua_State*, NULL), res, aux); } } } +#define luaV_fastget(t,k,res,f, tag) \ + (tag = (!ttistable(t) ? LUA_VNOTABLE : f(hvalue(t), k, res))) /* ** Special case of 'luaV_fastget' for integers, inlining the fast case ** of 'luaH_getint'. */ -#define luaV_fastgeti(t,k,res,aux) \ - { if (!ttistable(t)) setnotableV(aux); \ - else { luaH_fastgeti(hvalue(t), k, res, aux); } } +#define luaV_fastgeti(t,k,res,tag) \ + if (!ttistable(t)) tag = LUA_VNOTABLE; \ + else { luaH_fastgeti(hvalue(t), k, res, tag); } #define luaV_fastset(t,k,val,hres,f) \ @@ -122,10 +120,8 @@ LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode); LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, F2Imod mode); LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); -#define luaV_finishget(L,t,key,val,aux) \ - luaV_finishget_(L,t,key,val,ttypetagV(aux)) -LUAI_FUNC void luaV_finishget_ (lua_State *L, const TValue *t, TValue *key, - StkId val, int tag); +LUAI_FUNC int luaV_finishget (lua_State *L, const TValue *t, TValue *key, + StkId val, int tag); LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, TValue *val, int aux); LUAI_FUNC void luaV_finishOp (lua_State *L); -- cgit v1.2.3-55-g6feb