From 98f2f852dd34588c0288c35ea986b84ac5f19dca Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 29 Nov 2015 13:52:48 +0000 Subject: [PATCH] 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 --- ChangeLog | 2 ++ src/winio.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8f21d80..96a3175c 100644 --- 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 * src/nano.c (main): Allow the user full control over the values of diff --git a/src/winio.c b/src/winio.c index 473b09a4..db2f66de 100644 --- 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) == -- 2.39.5