From f8d30826dda6ee8e99200de57a1997734b853db2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 16 May 2023 14:55:49 -0300 Subject: New table API for 'set' functions --- lvm.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lvm.h') diff --git a/lvm.h b/lvm.h index 704446c2..750a22b2 100644 --- a/lvm.h +++ b/lvm.h @@ -104,14 +104,27 @@ typedef enum { ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ !isempty(slot))) /* result not empty? */ -#define luaV_fastgeti1(t,k,val,aux) \ +#define luaV_fastgeti1(t,k,res,aux) \ if (!ttistable(t)) aux = HNOTATABLE; \ else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ if ((u - 1u < h->alimit)) { \ int tag = *getArrTag(h,u); \ if (tagisempty(tag)) aux = HNOTFOUND; \ - else { arr2val(h, u, tag, val); aux = HOK; }} \ - else { aux = luaH_getint1(h, u, val); }} + else { arr2val(h, u, tag, res); aux = HOK; }} \ + else { aux = luaH_getint1(h, u, res); }} + + +#define luaV_fastset1(t,k,val,aux,f) \ + (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, val))) + +#define luaV_fastseti1(t,k,val,aux) \ + if (!ttistable(t)) aux = HNOTATABLE; \ + else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \ + if ((u - 1u < h->alimit)) { \ + lu_byte *tag = getArrTag(h,u); \ + if (tagisempty(*tag)) aux = ~cast_int(u); \ + else { val2arr(h, u, tag, val); aux = HOK; }} \ + else { aux = luaH_setint1(h, u, val); }} /* @@ -122,6 +135,8 @@ typedef enum { { setobj2t(L, cast(TValue *,slot), v); \ luaC_barrierback(L, gcvalue(t), v); } +#define luaV_finishfastset1(L,t,v) luaC_barrierback(L, gcvalue(t), v) + /* ** Shift right is the same as shift left with a negative 'y' @@ -140,8 +155,8 @@ LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p, LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); LUAI_FUNC void luaV_finishget1 (lua_State *L, const TValue *t, TValue *key, StkId val, int aux); -LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, - TValue *val, const TValue *slot); +LUAI_FUNC void luaV_finishset1 (lua_State *L, const TValue *t, TValue *key, + TValue *val, int aux); LUAI_FUNC void luaV_finishOp (lua_State *L); LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); LUAI_FUNC void luaV_concat (lua_State *L, int total); -- cgit v1.2.3-55-g6feb