From 350e97d78e7803650c6dd2bf46fcfece8e2b4b32 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 23 Jul 2022 16:13:32 +0300 Subject: [PATCH] Speed up redisplay of long truncated lines * src/xdisp.c (forward_to_next_line_start): Fix logic of interpreting the result of Fnext_single_property_change. (reseat_at_next_visible_line_start): When ON_NEWLINE_P is zero, pass NULL to 'forward_to_next_line_start', to avoid costly bidi iteration when none is needed. This speeds up redisplay of very long lines under 'truncate-lines'. --- src/xdisp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 215a6d561ea..690f10b8403 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -7153,10 +7153,10 @@ forward_to_next_line_start (struct it *it, bool *skipped_p, || ((pos = Fnext_single_property_change (make_fixnum (start), Qdisplay, Qnil, make_fixnum (limit)), - NILP (pos)) + (NILP (pos) || XFIXNAT (pos) == limit)) && next_overlay_change (start) == ZV)) { - if (!it->bidi_p) + if (!it->bidi_p || !bidi_it_prev) { IT_CHARPOS (*it) = limit; IT_BYTEPOS (*it) = bytepos; @@ -7319,7 +7319,8 @@ reseat_at_next_visible_line_start (struct it *it, bool on_newline_p) bool skipped_p = false; struct bidi_it bidi_it_prev; bool newline_found_p - = forward_to_next_line_start (it, &skipped_p, &bidi_it_prev); + = forward_to_next_line_start (it, &skipped_p, + on_newline_p ? &bidi_it_prev : NULL); /* Skip over lines that are invisible because they are indented more than the value of IT->selective. */ @@ -7331,7 +7332,8 @@ reseat_at_next_visible_line_start (struct it *it, bool on_newline_p) eassert (IT_BYTEPOS (*it) == BEGV || FETCH_BYTE (IT_BYTEPOS (*it) - 1) == '\n'); newline_found_p = - forward_to_next_line_start (it, &skipped_p, &bidi_it_prev); + forward_to_next_line_start (it, &skipped_p, + on_newline_p ? &bidi_it_prev : NULL); } /* Position on the newline if that's what's requested. */ -- 2.39.5