Subject: bug#25706: 26.0.50; Slow C file fontification

From: Alan Mackenzie <[email-masked]>
Date: Mon, 30 Nov 2020 16:38:29 +0000

Hello, Mattias.

On Mon, Nov 30, 2020 at 13:46:30 +0100, Mattias Engdegård wrote:
> >> https://raw.githubusercontent.com/qca/qcamain_open_hal_public/master/hal/ar9300/osprey_reg_map_macro.h

> > I tried reproducing this on a pretty new laptop, and opening the file
> > in question (with your settings) took less than a second with Emacs
> > 28.

> My lappy is less new but not really that slow -- compared to the
> hardware of the original reporter it's a speed demon -- but opening the
> file takes almost 4 s here. More importantly, scrolling through the
> file is painfully slow.

> The code in the file is nothing out of the ordinary; it consists of
> macros that are 1-3 lines each; definitely not a pathological case. The
> entire fontification takes 64 s for this file.

> I'd say the complaint is warranted, even if the original reporter is no
> longer reachable. Reopen?

> Alan, do you have a diagnose?

Yes.  I've had a look at the file, and it's large and lacking in braces.
There are functions in CC Mode which search backwards for opening braces
to establish context.  When there are none, the search goes back to BOB.
Lots of these searches, not efficiently cached, take a long time.

It's a problem with CC Mode, not with the source file.  It's a known
problem, and not easy to fix.

-- 
Alan Mackenzie (Nuremberg, Germany).