From 412e9a4d952d47631feddfa4ec25a520ec75b103 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 11 Dec 2024 15:32:43 -0300 Subject: 'luaH_fastseti' uses 'checknoTM' The extra check in checknoTM (versus only checking whether there is a metatable) is cheap, and it is not that uncommon for a table to have a metatable without a __newindex metafield. --- ltable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ltable.h') diff --git a/ltable.h b/ltable.h index 9c4eb937..e4aa98f0 100644 --- a/ltable.h +++ b/ltable.h @@ -58,7 +58,7 @@ { Table *h = t; lua_Unsigned u = l_castS2U(k) - 1u; \ if ((u < h->asize)) { \ lu_byte *tag = getArrTag(h, u); \ - if (h->metatable == NULL || !tagisempty(*tag)) \ + if (checknoTM(h->metatable, TM_NEWINDEX) || !tagisempty(*tag)) \ { fval2arr(h, u, tag, val); hres = HOK; } \ else hres = ~cast_int(u); } \ else { hres = luaH_psetint(h, k, val); }} -- cgit v1.2.3-55-g6feb