From 3152cddb3d17e343f6efbe0f51cb3d1527a44c97 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Wed, 29 Jan 2025 22:16:36 +0100 Subject: [PATCH] In rehashtab, do counthash before adding asize Thanks alug! --- src/bluajit/lj_tab.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bluajit/lj_tab.c b/src/bluajit/lj_tab.c index 869c5f03c..27b3021dd 100644 --- a/src/bluajit/lj_tab.c +++ b/src/bluajit/lj_tab.c @@ -359,8 +359,14 @@ static void rehashtab(lua_State *L, GCtab *t, cTValue *ek) uint32_t total, asize, na, i; for (i = 0; i < LJ_MAX_ABITS; i++) bins[i] = 0; asize = countarray(t, bins); +#if 0 total = 1 + asize; total += counthash(t, bins, &asize); +#else + /* more closely matches vanilla lua when abusing undefined behavior (frictionfix.....) */ + total = counthash(t, bins, &asize); + total += 1 + asize; +#endif asize += countint(ek, bins); na = bestasize(bins, &asize); total -= na;