aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
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 /ltable.c
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 'ltable.c')
-rw-r--r--ltable.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ltable.c b/ltable.c
index 21a54f81..353e567b 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1001,7 +1001,7 @@ static int rawfinishnodeset (const TValue *slot, TValue *val) {
1001int luaH_psetint (Table *t, lua_Integer key, TValue *val) { 1001int luaH_psetint (Table *t, lua_Integer key, TValue *val) {
1002 if (keyinarray(t, key)) { 1002 if (keyinarray(t, key)) {
1003 lu_byte *tag = getArrTag(t, key - 1); 1003 lu_byte *tag = getArrTag(t, key - 1);
1004 if (!tagisempty(*tag)) { 1004 if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) {
1005 fval2arr(t, key, tag, val); 1005 fval2arr(t, key, tag, val);
1006 return HOK; /* success */ 1006 return HOK; /* success */
1007 } 1007 }