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 /lvm.h | |
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 'lvm.h')
-rw-r--r-- | lvm.h | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -78,19 +78,17 @@ typedef enum { | |||
78 | /* | 78 | /* |
79 | ** fast track for 'gettable' | 79 | ** fast track for 'gettable' |
80 | */ | 80 | */ |
81 | #define luaV_fastget(t,k,res,f, aux) \ | 81 | #define luaV_fastget(t,k,res,f, tag) \ |
82 | {if (!ttistable(t)) setnotableV(aux); \ | 82 | (tag = (!ttistable(t) ? LUA_VNOTABLE : f(hvalue(t), k, res))) |
83 | else { aux = f(hvalue(t), k); \ | ||
84 | if (!isemptyV(aux)) { setobjV(cast(lua_State*, NULL), res, aux); } } } | ||
85 | 83 | ||
86 | 84 | ||
87 | /* | 85 | /* |
88 | ** Special case of 'luaV_fastget' for integers, inlining the fast case | 86 | ** Special case of 'luaV_fastget' for integers, inlining the fast case |
89 | ** of 'luaH_getint'. | 87 | ** of 'luaH_getint'. |
90 | */ | 88 | */ |
91 | #define luaV_fastgeti(t,k,res,aux) \ | 89 | #define luaV_fastgeti(t,k,res,tag) \ |
92 | { if (!ttistable(t)) setnotableV(aux); \ | 90 | if (!ttistable(t)) tag = LUA_VNOTABLE; \ |
93 | else { luaH_fastgeti(hvalue(t), k, res, aux); } } | 91 | else { luaH_fastgeti(hvalue(t), k, res, tag); } |
94 | 92 | ||
95 | 93 | ||
96 | #define luaV_fastset(t,k,val,hres,f) \ | 94 | #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); | |||
122 | LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, | 120 | LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, |
123 | F2Imod mode); | 121 | F2Imod mode); |
124 | LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); | 122 | LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); |
125 | #define luaV_finishget(L,t,key,val,aux) \ | 123 | LUAI_FUNC int luaV_finishget (lua_State *L, const TValue *t, TValue *key, |
126 | luaV_finishget_(L,t,key,val,ttypetagV(aux)) | 124 | StkId val, int tag); |
127 | LUAI_FUNC void luaV_finishget_ (lua_State *L, const TValue *t, TValue *key, | ||
128 | StkId val, int tag); | ||
129 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | 125 | LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, |
130 | TValue *val, int aux); | 126 | TValue *val, int aux); |
131 | LUAI_FUNC void luaV_finishOp (lua_State *L); | 127 | LUAI_FUNC void luaV_finishOp (lua_State *L); |