Subject: bug#56682: Fix the long lines font locking related slowdowns

From: Gregory Heytings <[email-masked]>
Date: Thu, 04 Aug 2022 11:21:23 +0000

>
> By the way, playing with Alan's example here a bit...  To recap, this is 
> the test case (in a .cc file):
>
> ---
> char long_line[] = R"foo(
>
> )foo"
> ---
>
> If I insert a 1M long line there (with `C-y'), Emacs will hang 
> indefinitely.  Wasn't the long-line stuff supposed to trigger in these 
> situations?  Or is it hanging in some cc-mode stuff before we get that 
> far?
>

No wonder.  CC Mode is a slow mode, and one of the worst offenders here. 
In this cas, IIUC, what you see is because CC Mode adds c-after-change to 
after-change-functions, which has the effect that

(put-text-property 27 1000028 'face 'font-lock-string-face)

is called no less than 1335 times after that C-y.