diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-13 15:45:57 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-12-13 15:45:57 -0300 |
commit | 5d8b5b9290c932bdfd7dcc670a5af957bdd58392 (patch) | |
tree | 17915e03d62517c47ddf3dd7db6c07596f8d5748 /lapi.c | |
parent | 40565b4a089f44fdcb16f4ed0080b0ca3755e4aa (diff) | |
download | lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.tar.gz lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.tar.bz2 lua-5d8b5b9290c932bdfd7dcc670a5af957bdd58392.zip |
Changed signal of GC debt
Positive debts seems more natural then negative ones.
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1168,8 +1168,8 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1168 | g->gcstp = 0; /* allow GC to run (bit GCSTPGC must be zero here) */ | 1168 | g->gcstp = 0; /* allow GC to run (bit GCSTPGC must be zero here) */ |
1169 | if (todo == 0) | 1169 | if (todo == 0) |
1170 | todo = 1 << g->gcstepsize; /* standard step size */ | 1170 | todo = 1 << g->gcstepsize; /* standard step size */ |
1171 | while (todo + g->GCdebt > 0) { /* enough to run a step? */ | 1171 | while (todo >= g->GCdebt) { /* enough to run a step? */ |
1172 | todo += g->GCdebt; /* decrement 'todo' (debt is usually negative) */ | 1172 | todo -= g->GCdebt; /* decrement 'todo' */ |
1173 | luaC_step(L); /* run one basic step */ | 1173 | luaC_step(L); /* run one basic step */ |
1174 | didsomething = 1; | 1174 | didsomething = 1; |
1175 | if (g->gckind == KGC_GEN) /* minor collections? */ | 1175 | if (g->gckind == KGC_GEN) /* minor collections? */ |
@@ -1177,8 +1177,8 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1177 | else if (g->gcstate == GCSpause) | 1177 | else if (g->gcstate == GCSpause) |
1178 | break; /* don't run more than one cycle */ | 1178 | break; /* don't run more than one cycle */ |
1179 | } | 1179 | } |
1180 | /* add remaining 'todo' to total debt */ | 1180 | /* remove remaining 'todo' from total debt */ |
1181 | luaE_setdebt(g, todo + g->GCdebt); | 1181 | luaE_setdebt(g, g->GCdebt - todo); |
1182 | g->gcstp = oldstp; /* restore previous state */ | 1182 | g->gcstp = oldstp; /* restore previous state */ |
1183 | if (didsomething && g->gcstate == GCSpause) /* end of cycle? */ | 1183 | if (didsomething && g->gcstate == GCSpause) /* end of cycle? */ |
1184 | res = 1; /* signal it */ | 1184 | res = 1; /* signal it */ |