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.
master
Benno Schulenberg 2021-01-24 16:56:31 +01:00
parent 6cbb7bc443
commit 0508520b47
1 changed files with 10 additions and 10 deletions

View File

@ -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;