]> git.eshelyaron.com Git - emacs.git/commitdiff
Speed up maybe_gc when GC is inhibited
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 21 Jul 2019 18:20:07 +0000 (11:20 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 21 Jul 2019 18:24:11 +0000 (11:24 -0700)
* 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

index b7ba886482e0e0fe6bc82417a457dc56c444d019..50015808e592a88ef9bd8f4c146c133f1803b8e8 100644 (file)
@@ -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;
 }