Optimizations for 'lua_rawgeti' and 'lua_rawseti'
'lua_rawgeti' now uses "fast track"; 'lua_rawseti' still calls 'luaH_setint', but the latter was recoded to avoid extra overhead when writing to the array part after 'alimit'.
This commit is contained in:
19
ltable.h
19
ltable.h
@@ -45,6 +45,25 @@
|
||||
#define nodefromval(v) cast(Node *, (v))
|
||||
|
||||
|
||||
|
||||
#define luaH_fastgeti(t,k,res,hres) \
|
||||
{ Table *h = t; lua_Unsigned u = l_castS2U(k); \
|
||||
if ((u - 1u < h->alimit)) { \
|
||||
int tag = *getArrTag(h,(u)-1u); \
|
||||
if (tagisempty(tag)) hres = HNOTFOUND; \
|
||||
else { farr2val(h, u, tag, res); hres = HOK; }} \
|
||||
else { hres = luaH_getint(h, u, res); }}
|
||||
|
||||
|
||||
#define luaH_fastseti(t,k,val,hres) \
|
||||
{ Table *h = t; lua_Unsigned u = l_castS2U(k); \
|
||||
if ((u - 1u < h->alimit)) { \
|
||||
lu_byte *tag = getArrTag(h,(u)-1u); \
|
||||
if (tagisempty(*tag)) hres = ~cast_int(u); \
|
||||
else { fval2arr(h, u, tag, val); hres = HOK; }} \
|
||||
else { hres = luaH_psetint(h, u, val); }}
|
||||
|
||||
|
||||
/* results from get/pset */
|
||||
#define HOK 0
|
||||
#define HNOTFOUND 1
|
||||
|
||||
Reference in New Issue
Block a user