From 72ad00f9d02aec94816deb3d4d3abd2c4b751a44 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 2 Mar 2020 19:36:10 +0100 Subject: [PATCH] tweaks: change an integer to a short, and reshuffle it for better packing A short allows for more than 32 thousand values, and the maximum number of multiline regexes in any of the current syntaxes is... just four. Reshuffle it to the beginning also because it is used the most often. --- src/color.c | 2 +- src/nano.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/color.c b/src/color.c index 0b411393..701dab04 100644 --- a/src/color.c +++ b/src/color.c @@ -266,7 +266,7 @@ void set_up_multicache(linestruct *line) { line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short)); - for (int index = 0; index < openfile->syntax->nmultis; index++) + for (short index = 0; index < openfile->syntax->nmultis; index++) line->multidata[index] = -1; } diff --git a/src/nano.h b/src/nano.h index 953a2626..71112fac 100644 --- a/src/nano.h +++ b/src/nano.h @@ -178,10 +178,12 @@ typedef enum { /* Structure types. */ #ifdef ENABLE_COLOR typedef struct colortype { + short id; + /* An ordinal number (if this color combo is for a multiline regex). */ short fg; - /* This syntax's foreground color. */ + /* This combo's foreground color. */ short bg; - /* This syntax's background color. */ + /* This combo's background color. */ short pairnum; /* The pair number for this foreground/background color combination. */ int attributes; @@ -191,9 +193,7 @@ typedef struct colortype { regex_t *end; /* The compiled regular expression for 'end=', if any. */ struct colortype *next; - /* Next set of colors. */ - int id; - /* Basic id for assigning to lines later. */ + /* Next color combination. */ } colortype; typedef struct regexlisttype { @@ -241,7 +241,7 @@ typedef struct syntaxtype { #endif colortype *color; /* The colors and their regexes used in this syntax. */ - int nmultis; + short nmultis; /* How many multiline regex strings this syntax has. */ struct syntaxtype *next; /* Next syntax. */