From 76d83070c4ab3242e388d5b6a5f7ff03afd1b4c3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 21 Jan 2017 16:50:52 +0100 Subject: [PATCH] tweaks: elide a variable plus its corresponding dark logic Just assign the 'CNONE' value upfront, instead of figuring out at the end of the line whether anything has been assigned yet. Also, the old logic would leave unmarked a line that contains a start match without any terminating end match. Not serious, but not right. --- src/color.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/color.c b/src/color.c index f3ac58ce..927dd016 100644 --- a/src/color.c +++ b/src/color.c @@ -413,13 +413,15 @@ void precalc_multicolorinfo(void) continue; for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) { - int startx = 0, nostart = 0; + int startx = 0; int linelen = strlen(fileptr->data); alloc_multidata_if_needed(fileptr); + /* Assume nothing applies until proven otherwise below. */ + fileptr->multidata[ink->id] = CNONE; - while ((nostart = regexec(ink->start, &fileptr->data[startx], 1, - &startmatch, (startx == 0) ? 0 : REG_NOTBOL)) == 0) { + while (regexec(ink->start, &fileptr->data[startx], 1, + &startmatch, (startx == 0) ? 0 : REG_NOTBOL) == 0) { /* Look for an end, and start marking how many lines are * encompassed, which should speed up rendering later. */ startx += startmatch.rm_eo; @@ -463,11 +465,6 @@ void precalc_multicolorinfo(void) /* Skip to the end point of the match. */ startx = endmatch.rm_eo; } - - if (nostart && startx == 0) { - fileptr->multidata[ink->id] = CNONE; - continue; - } } } }