[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25706: 26.0.50; Slow C file fontification
From: |
Mattias Engdegård |
Subject: |
bug#25706: 26.0.50; Slow C file fontification |
Date: |
Mon, 30 Nov 2020 17:53:04 +0100 |
30 nov. 2020 kl. 17.38 skrev Alan Mackenzie <acm@muc.de>:
> 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.
Actually, it's the underscores!
Demo: fill a file with the line pairs
#define abc_defg_hij_klm__nop_qrst_uvw_xyz_w__ooa_cin_e__aoi__uynv(s) \
0
repeated 1000 times, thus making it 2000 lines. Save as something.h. Slow!
Now replace each underscore with a letter. Save. Fast!
Fontifying the 2000 line file (with underscores) takes longer than the original
80000 line file.
I started going through c-find-decl-spots and c-find-decl-prefix-search
(together there are while statements nested 4 deep) but am not sure exactly
where the trouble is. A regexp? Something syntax-char related (since '_' has
symbol syntax, not word)?
CC-mode in general thrashes the regexp cache; the miss rate is at 27 % for the
original file, which is way too high. Enlarging the cache enough to eliminate
misses helps, but not nearly enough.