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.
This commit is contained in:
Roberto Ierusalimschy
2024-01-25 13:44:49 -03:00
parent 3e9dbe143d
commit b34a97a4af
2 changed files with 5 additions and 4 deletions

View File

@@ -1001,7 +1001,7 @@ static int rawfinishnodeset (const TValue *slot, TValue *val) {
int luaH_psetint (Table *t, lua_Integer key, TValue *val) {
if (keyinarray(t, key)) {
lu_byte *tag = getArrTag(t, key - 1);
if (!tagisempty(*tag)) {
if (!tagisempty(*tag) || checknoTM(t->metatable, TM_NEWINDEX)) {
fval2arr(t, key, tag, val);
return HOK; /* success */
}