From fa2f294dd1269115bf9cf534dd38553e2f606801 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 9 Dec 2022 16:35:19 -0300 Subject: Reduce calls to 'luaC_step' when GC is stopped --- lgc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index 2e749902..a3094ff5 100644 --- a/lgc.c +++ b/lgc.c @@ -1681,12 +1681,15 @@ static void incstep (lua_State *L, global_State *g) { } /* -** performs a basic GC step if collector is running +** Performs a basic GC step if collector is running. (If collector is +** not running, set a reasonable debt to avoid it being called at +** every single check.) */ void luaC_step (lua_State *L) { global_State *g = G(L); - lua_assert(!g->gcemergency); - if (gcrunning(g)) { /* running? */ + if (!gcrunning(g)) /* not running? */ + luaE_setdebt(g, -2000); + else { if(isdecGCmodegen(g)) genstep(L, g); else -- cgit v1.2.1