From b34a97a4af5c9e973915c07dba918d95009e0acd Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 25 Jan 2024 13:44:49 -0300 Subject: Small optimization in 'luaH_psetint' It is quite common to write to empty but existing cells in the array part of a table, so 'luaH_psetint' checks for the common case that the table doesn't have a newindex metamethod to complete the write. --- ltm.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ltm.h') diff --git a/ltm.h b/ltm.h index f3872655..3c49713a 100644 --- a/ltm.h +++ b/ltm.h @@ -60,11 +60,12 @@ typedef enum { */ #define notm(tm) ttisnil(tm) +#define checknoTM(mt,e) ((mt) == NULL || (mt)->flags & (1u<<(e))) -#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ - ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) +#define gfasttm(g,mt,e) \ + (checknoTM(mt, e) ? NULL : luaT_gettm(mt, e, (g)->tmname[e])) -#define fasttm(l,et,e) gfasttm(G(l), et, e) +#define fasttm(l,mt,e) gfasttm(G(l), mt, e) #define ttypename(x) luaT_typenames_[(x) + 1] -- cgit v1.2.3-55-g6feb