commit 4c566c79033ea106588afd23389452588246a18f
parent 73a07215cc705ddbfdda5f324de43d66bd94e5bd
Author: Rishabh Dave <rishabhddave@gmail.com>
Date: Sun, 17 Jul 2016 18:59:07 +0530
tweaks: reduce the number of wattron/wattrof calls
Also, compose the coloring attributes during initialization
instead of every time when painting something.
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Diffstat:
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/color.c b/src/color.c
@@ -97,6 +97,9 @@ void set_colorpairs(void)
this_color->pairnum = clr_pair;
clr_pair++;
}
+
+ this_color->attributes = COLOR_PAIR(this_color->pairnum) |
+ (this_color->bright ? A_BOLD : A_NORMAL);
}
}
}
diff --git a/src/nano.h b/src/nano.h
@@ -210,6 +210,8 @@ typedef struct colortype {
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
+ int attributes;
+ /* Pair number and brightness composed into ready-to-use attributes. */
int rex_flags;
/* The regex compilation flags (with or without REG_ICASE). */
char *start_regex;
diff --git a/src/winio.c b/src/winio.c
@@ -2265,9 +2265,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
regmatch_t endmatch;
/* Match position for end_regex. */
- if (varnish->bright)
- wattron(edit, A_BOLD);
- wattron(edit, COLOR_PAIR(varnish->pairnum));
+ wattron(edit, varnish->attributes);
/* Two notes about regexec(). A return value of zero means
* that there is a match. Also, rm_eo is the first
* non-matching character after the match. */
@@ -2524,8 +2522,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
}
}
tail_of_loop:
- wattroff(edit, A_BOLD);
- wattroff(edit, COLOR_PAIR(varnish->pairnum));
+ wattroff(edit, varnish->attributes);
}
}
#endif /* !DISABLE_COLOR */