[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.e
From: |
Dmitry Gutov |
Subject: |
bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el |
Date: |
Wed, 3 Mar 2021 00:37:08 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 03.03.2021 00:14, Theodor Thornhill via Bug reports for GNU Emacs,
the Swiss army knife of text editors wrote:
I'm interested in seeing if I could gain some more
performance by short circuiting after the first iteration of a match on
the same line. In my test scenario there are a lot of matches on the
same huge line. What do you think?
You probably mean to short-circuit as soon as you reach the target
column (there might be multiple matches within those 500 chars),
skipping the rest of the matches on the same line.
Sounds worth a try.
Another approach would be to truncate the line sometime earlier, like:
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..63a17a8521 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1531,7 +1531,10 @@ xref-matches-in-files
(while (re-search-forward grep-re nil t)
(push (list (string-to-number (match-string line-group))
(match-string file-group)
- (buffer-substring-no-properties (point)
(line-end-position)))
+ (buffer-substring-no-properties (point)
+ (min
+ (+ (point) 500)
+ (line-end-position))))
hits)))
(xref--convert-hits (nreverse hits) regexp)))
...of course, ideally we would keep all contents of the line somewhere
in memory and truncate with (setq truncate-line t). But IIRC Juri said
this didn't give us as much of a speedup as we'd want.
Another question: how many hits do you usually have in that huge
one-line file? If it's more than 2-3, it might be that our current
algorithm which creates "match objects" will duplicate this string
unnecessarily N times (which is the number of hits), in
xref--collect-matches-1, to then cut it up and merge into one line again
when printing the buffer. In which case the patch above should also show
a healthy improvement, but we could figure out something better instead.
Anyway, please benchmark your "earlier short-circuit" approach and then
the above patch too.
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/01
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/01
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Juri Linkov, 2021/03/02
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/02
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/02
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/02
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/02
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el,
Dmitry Gutov <=
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/03
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/03
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/03
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/06
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/06
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/06
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/07
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Dmitry Gutov, 2021/03/07
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/07
- bug#46859: 28.0.50; [PATCH]: Add option to truncate long lines in xref.el, Theodor Thornhill, 2021/03/07