Subject: bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el

From: Dmitry Gutov <[email-masked]>
Date: Thu, 4 Mar 2021 04:50:48 +0200

Hi Juri,

On 03.03.2021 21:59, Juri Linkov wrote:
>> We currently don't visit the file buffer if it's not already visited,
>> parsing the line in a temp buffer instead. That approach resulted in a nice
>> perf improvement.
> 
> Reusing visited files is a nice feature, but still needs a fix.
> 
> Test case: visit emacs/src/xdisp.c and type
> 
>    C-x p g expose_frame RET
> 
> See that not all lines from xdisp.c have font-lock highlighting.
> After applying this patch, all xref output lines from xdisp.c
> have font-lock faces:

I thought about this, but applying font-lock rules is not exactly a 
trivial action. So I figured we better avoid it (and only call 
syntax-propertize when necessary) to get the best performance possible.

Have you tried benchmarking with and without your patch? Particular case 
of interest: many files, each already visited, with 1 match in each of 
them. Or few matches.

The opposite would be one file with many matches inside of it. This case 
should be relatively inexpensive for this patch, but it's worth 
measuring to compare too.

P.S. The "(unless syntax-needed" guard in the proposed patch is not needed.