>From d02c2f7f6507105605ed0596a7e26acd5b3b8122 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 21 Jul 2019 11:20:07 -0700 Subject: [PATCH] Speed up maybe_gc when GC is inhibited * src/alloc.c (allow_garbage_collection) (inhibit_garbage_collection): Temporarily bump consing_until_gc, to improve performance of maybe_gc while garbage collection is inhibited. Suggested by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00511.html --- src/alloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index b7ba886482..50015808e5 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5501,11 +5501,14 @@ staticpro (Lisp_Object const *varaddress) Protection from GC ***********************************************************************/ -/* Temporarily prevent garbage collection. */ +/* Temporarily prevent garbage collection. Temporarily bump + consing_until_gc to speed up maybe_gc when GC is inhibited. */ static void -allow_garbage_collection (void) +allow_garbage_collection (void *ptr) { + object_ct *p = ptr; + consing_until_gc = *p; garbage_collection_inhibited--; } @@ -5513,9 +5516,10 @@ ptrdiff_t inhibit_garbage_collection (void) { ptrdiff_t count = SPECPDL_INDEX (); - - record_unwind_protect_void (allow_garbage_collection); + object_ct consing = consing_until_gc; + record_unwind_protect_ptr (allow_garbage_collection, &consing); garbage_collection_inhibited++; + consing_until_gc = OBJECT_CT_MAX; return count; } -- 2.17.1