commit 055e262b56e42cf8d591851513b5e7ce324d2d31
parent 9d8388e8367fc6003eb3c13ed8fc44fe0b4a28eb
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 24 Jan 2021 12:31:52 +0100
tweaks: stop evaluating a rule when the match is offscreen to the right
When the match of a coloring regex is beyond the width of the screen,
there is no point in continuing to evaluate the regex for the rest of
the line, because any other matches will be offscreen too.
This will save some time when there are several overlong lines.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -2524,10 +2524,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
match.rm_eo += index;
index = match.rm_eo;
- /* If the matching part is not visible, skip it. */
- if (match.rm_eo <= from_x || match.rm_so >= till_x)
+ /* 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;
+
start_col = (match.rm_so <= from_x) ?
0 : wideness(line->data,
match.rm_so) - from_col;