From: Ivan Maidanski Date: Fri, 4 May 2018 20:28:22 +0000 (+0300) Subject: Do not rebuild_root_index unless remove_root_at_pos is called X-Git-Tag: v8.0.0~203 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=066a258133947bde0ae78d8816bdf4dd6bb913cc;p=gc Do not rebuild_root_index unless remove_root_at_pos is called * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_tmp_roots, GC_remove_roots_inner): Call GC_rebuild_root_index() only if GC_remove_root_at_pos() is called at least once. --- diff --git a/mark_rts.c b/mark_rts.c index 6e297abd..1499e457 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -317,6 +317,9 @@ STATIC void GC_remove_root_at_pos(int i) STATIC void GC_remove_tmp_roots(void) { int i; +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) + int old_n_roots = n_root_sets; +# endif for (i = 0; i < n_root_sets; ) { if (GC_static_roots[i].r_tmp) { @@ -326,7 +329,8 @@ STATIC void GC_remove_tmp_roots(void) } } # if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) - GC_rebuild_root_index(); + if (n_root_sets < old_n_roots) + GC_rebuild_root_index(); # endif } #endif @@ -352,15 +356,19 @@ STATIC void GC_remove_tmp_roots(void) STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e) { int i; + GC_bool rebuild = FALSE; + for (i = 0; i < n_root_sets; ) { if ((word)GC_static_roots[i].r_start >= (word)b && (word)GC_static_roots[i].r_end <= (word)e) { GC_remove_root_at_pos(i); + rebuild = TRUE; } else { i++; } } - GC_rebuild_root_index(); + if (rebuild) + GC_rebuild_root_index(); } #endif /* !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) */