commit 0508520b477a9612c9273491dd74418d299c8519
parent 6cbb7bc4439d82d5718b6eb0e117de6fa3f16146
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 24 Jan 2021 16:56:31 +0100
tweaks: reshuffle three conditions into a better order
When a zero-length match is beyond the width of the screen, there
is no point in continuing evaluating the rule, so the check for
"offscreen to the right" needs to come first. The check for a
zero-width match needs to come second because otherwise we would
get stuck on such a match when it is offscreen to the left.
Diffstat:
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -2513,25 +2513,25 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
break;
- /* If the match is of length zero, skip over it. */
- if (match.rm_so == match.rm_eo) {
- index = step_right(line->data, index + match.rm_eo);
- continue;
- }
-
/* Translate the match to the beginning of the line. */
match.rm_so += index;
match.rm_eo += index;
index = match.rm_eo;
+ /* If the match is offscreen to the right, this rule is done. */
+ if (match.rm_so >= till_x)
+ break;
+
+ /* If the match has length zero, advance over it. */
+ if (match.rm_so == match.rm_eo) {
+ index = step_right(line->data, index);
+ continue;
+ }
+
/* If the match is offscreen to the left, skip to next. */
if (match.rm_eo <= from_x)
continue;
- /* If the match is off to the right, this rule is done. */
- if (match.rm_so >= till_x)
- break;
-
if (match.rm_so > from_x)
start_col = wideness(line->data, match.rm_so) - from_col;