early. */
eassert (! early_abort);
+ rbc_quitcounter = 0;
+
Fundo_boundary ();
- ptrdiff_t count = SPECPDL_INDEX ();
- record_unwind_protect (save_excursion_restore, save_excursion_save ());
+ bool modification_hooks_inhibited = false;
+ record_unwind_protect_excursion ();
+ /* We are going to make a lot of small modifications, and having the
+ modification hooks called for each of them will slow us down.
+ Instead, we announce a single modification for the entire
+ modified region. But don't do that if the caller inhibited
+ modification hooks, because then they don't want that. */
+ ptrdiff_t from, to;
+ if (!inhibit_modification_hooks)
+ {
+ ptrdiff_t k, l;
+
+ /* Find the first character position to be changed. */
+ for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++)
+ ;
+ from = BEGV + k;
+
+ /* Find the last character position to be changed. */
+ for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--)
+ ;
+ to = BEGV + l;
+ prepare_to_modify_buffer (from, to, NULL);
+ specbind (Qinhibit_modification_hooks, Qt);
+ modification_hooks_inhibited = true;
+ }
+
ptrdiff_t i = size_a;
ptrdiff_t j = size_b;
/* Walk backwards through the lists of changes. This was also
--i;
--j;
}
- unbind_to (count, Qnil);
- SAFE_FREE ();
++ SAFE_FREE_UNBIND_TO (count, Qnil);
+ rbc_quitcounter = 0;
- return SAFE_FREE_UNBIND_TO (count, Qnil);
+ if (modification_hooks_inhibited)
+ {
+ ptrdiff_t updated_to = to + ZV - BEGV - size_a;
+ signal_after_change (from, to - from, updated_to - from);
+ update_compositions (from, updated_to, CHECK_INSIDE);
+ }
+
+ return Qnil;
}
static void