tweaks: reshuffle an 'if' out of a function, and rename the function

This commit is contained in:
Benno Schulenberg 2019-06-23 12:15:19 +02:00
parent 8c7b6bd21a
commit d8c840692e
3 changed files with 10 additions and 11 deletions

View File

@ -295,7 +295,8 @@ void check_the_multis(linestruct *line)
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
return;
alloc_multidata_if_needed(line);
if (line->multidata == NULL)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
@ -329,14 +330,12 @@ void check_the_multis(linestruct *line)
}
/* Allocate (for one line) the cache space for multiline color regexes. */
void alloc_multidata_if_needed(linestruct *fileptr)
void set_up_multicache(linestruct *line)
{
if (fileptr->multidata == NULL) {
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (int i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1;
}
for (int index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
}
/* Precalculate the multi-line start and end regex info so we can
@ -352,7 +351,7 @@ void precalc_multicolorinfo(void)
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
alloc_multidata_if_needed(line);
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */

View File

@ -243,7 +243,7 @@ void set_colorpairs(void);
void color_init(void);
void color_update(void);
void check_the_multis(linestruct *line);
void alloc_multidata_if_needed(linestruct *fileptr);
void set_up_multicache(linestruct *line);
void precalc_multicolorinfo(void);
#endif

View File

@ -2467,8 +2467,8 @@ void edit_draw(linestruct *fileptr, const char *converted,
const colortype *varnish = openfile->colorstrings;
/* If there are multiline regexes, make sure there is a cache. */
if (openfile->syntax->nmultis > 0)
alloc_multidata_if_needed(fileptr);
if (openfile->syntax->nmultis > 0 && fileptr->multidata == NULL)
set_up_multicache(fileptr);
/* Iterate through all the coloring regexes. */
for (; varnish != NULL; varnish = varnish->next) {