commit 98f2f852dd34588c0288c35ea986b84ac5f19dca
parent ee33503402c1af31216694f3776dfd15d898e82d
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 29 Nov 2015 13:52:48 +0000
Deleting two redundant conditions, and moving the least frequent case
to the end.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -7,6 +7,8 @@
(because the coloured part is horizontally scrolled off), nevertheless
set the multidata to CBEGINBEFORE. This fixes Savannah bug #46545.
* src/winio.c (edit_draw): Use the main cache-allocation routine.
+ * src/winio.c (edit_draw): Delete two redundant conditions, and move
+ the least frequent case to the end.
2015-11-28 Benno Schulenberg <bensberg@justemail.net>
* src/nano.c (main): Allow the user full control over the values of
diff --git a/src/winio.c b/src/winio.c
@@ -2550,7 +2550,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
}
k = startmatch.rm_eo;
}
- } else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) {
+ } else {
/* This is a multi-line regex. There are two steps.
* First, we have to see if the beginning of the line is
* colored by a start on an earlier line, and an end on
@@ -2569,10 +2569,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
const filestruct *end_line;
short md = fileptr->multidata[tmpcolor->id];
- if (md == -1)
- /* Assume this until we know otherwise. */
- fileptr->multidata[tmpcolor->id] = CNONE;
- else if (md == CNONE)
+ /* First see if the multidata was maybe calculated earlier. */
+ if (md == CNONE)
goto end_of_loop;
else if (md == CWHOLELINE) {
mvwaddnstr(edit, line, 0, converted, -1);
@@ -2586,7 +2584,9 @@ void edit_draw(filestruct *fileptr, const char *converted, int
endmatch.rm_eo) - start);
mvwaddnstr(edit, line, 0, converted, paintlen);
goto end_of_loop;
- }
+ } if (md == -1)
+ /* Assume this until proven otherwise below. */
+ fileptr->multidata[tmpcolor->id] = CNONE;
while (start_line != NULL && regexec(tmpcolor->start,
start_line->data, 1, &startmatch, 0) ==