aboutsummaryrefslogtreecommitdiff
path: root/ltm.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-01-25 13:44:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-01-25 13:44:49 -0300
commitb34a97a4af5c9e973915c07dba918d95009e0acd (patch)
treec5fca69c78260918dd950ab4013fc50fccd4090b /ltm.h
parent3e9dbe143d3338f5f13a5e421ea593adff482da0 (diff)
downloadlua-b34a97a4af5c9e973915c07dba918d95009e0acd.tar.gz
lua-b34a97a4af5c9e973915c07dba918d95009e0acd.tar.bz2
lua-b34a97a4af5c9e973915c07dba918d95009e0acd.zip
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.
Diffstat (limited to 'ltm.h')
-rw-r--r--ltm.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/ltm.h b/ltm.h
index f3872655..3c49713a 100644
--- a/ltm.h
+++ b/ltm.h
@@ -60,11 +60,12 @@ typedef enum {
60*/ 60*/
61#define notm(tm) ttisnil(tm) 61#define notm(tm) ttisnil(tm)
62 62
63#define checknoTM(mt,e) ((mt) == NULL || (mt)->flags & (1u<<(e)))
63 64
64#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 65#define gfasttm(g,mt,e) \
65 ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 66 (checknoTM(mt, e) ? NULL : luaT_gettm(mt, e, (g)->tmname[e]))
66 67
67#define fasttm(l,et,e) gfasttm(G(l), et, e) 68#define fasttm(l,mt,e) gfasttm(G(l), mt, e)
68 69
69#define ttypename(x) luaT_typenames_[(x) + 1] 70#define ttypename(x) luaT_typenames_[(x) + 1]
70 71