From 53fe7ba26afe351ff6438bd21b7517e35c80c363 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 6 Feb 2021 16:56:22 +0100 Subject: [PATCH] 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. --- src/color.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/color.c b/src/color.c index 2310f982..a355ddd0 100644 --- 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; }