commit 53fe7ba26afe351ff6438bd21b7517e35c80c363
parent 7e04fea92b671aa5a80aa36210f032392b0fbf8e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 6 Feb 2021 16:56:22 +0100
tweaks: be slightly more efficient in marking lines as WOULDBE
Take two conditions that are relevant only for a rather unlikely case
(a start match without a corresponding end match) out of an inner loop.
Give the case its own, dedicated loop.
Diffstat:
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/color.c b/src/color.c
@@ -310,12 +310,6 @@ void precalc_multicolorinfo(void)
for (line = openfile->filetop; line != NULL; line = line->next) {
int index = 0;
- /* For an unpaired start match, mark each remaining line. */
- if (line->prev && line->prev->multidata[ink->id] == WOULDBE) {
- line->multidata[ink->id] = WOULDBE;
- continue;
- }
-
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = NOTHING;
@@ -350,7 +344,10 @@ void precalc_multicolorinfo(void)
1, &endmatch, 0) != 0)
tailline = tailline->next;
+ /* When there is no end match, mark relevant lines as such. */
if (tailline == NULL) {
+ for (; line->next != NULL; line = line->next)
+ line->multidata[ink->id] = WOULDBE;
line->multidata[ink->id] = WOULDBE;
break;
}