From 375d22b41260d9229485dcdedffda638d016720c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 6 Dec 2022 15:26:24 +0900 Subject: [PATCH] gc.c (clear_all_old): avoid calling GC twice in the function --- src/gc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gc.c b/src/gc.c index 7b9f098b5..443b778d9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1287,12 +1287,13 @@ clear_all_old(mrb_state *mrb, mrb_gc *gc) /* finish the half baked GC */ incremental_gc_finish(mrb, gc); } - - /* Sweep the dead objects, then reset all the live objects - * (including all the old objects, of course) to white. */ - gc->generational = FALSE; - prepare_incremental_sweep(mrb, gc); - incremental_gc_finish(mrb, gc); + else { + /* Sweep the dead objects, then reset all the live objects + * (including all the old objects, of course) to white. */ + gc->generational = FALSE; + prepare_incremental_sweep(mrb, gc); + incremental_gc_finish(mrb, gc); + } gc->generational = origin_mode; /* The gray objects have already been painted as white */