Subject: bug#64391: buffer narrowing slowdown regression in emacs 29

From: Mattias Engdegård <[email-masked]>
Date: Sat, 1 Jul 2023 13:37:08 +0200

1 juli 2023 kl. 06.59 skrev Andrew Cohen <[email-masked]>:

> Just for fun I simply commented it out (since the test code doesn't use
> labeled restrictions) and ran the test code, and the problem disappears:

The attached patch combines narrow-to-region and internal--label-restriction into a single function, internal--narrow-to-region. (We could also add the label as an optional argument to narrow-to-region.)

As a result, the up-front consing and marker allocation disappear entirely for normal (unlabelled) narrowing, as does the expensive buffer-local `outermost-restriction` variable.

Labelled narrowing is almost as expensive as before but is, we hope, less common. Maybe we can work separately on reducing its cost.

(And to those reading the patch: yes, some work on doc strings is needed. Suggestions welcome.)