Not bothering to keep the compiled regular expression when it matched.
Stopping instead to call malloc() pointlessly. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5706 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
ce32cb0f6b
commit
2070d3a26f
|
@ -1,3 +1,8 @@
|
||||||
|
2016-03-04 Benno Schulenberg <bensberg@justemail.net>
|
||||||
|
* src/color.c (found_in_list): Don't bother keeping the compiled
|
||||||
|
regular expression when it matched -- drop this tiny optimization
|
||||||
|
for when opening multiple files. Instead stop calling malloc().
|
||||||
|
|
||||||
2016-03-01 Benno Schulenberg <bensberg@justemail.net>
|
2016-03-01 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* src/rcfile.c (parse_syntax), src/color.c (color_update): Don't
|
* src/rcfile.c (parse_syntax), src/color.c (color_update): Don't
|
||||||
bother discarding a duplicate syntax (it's too rare, saves little
|
bother discarding a duplicate syntax (it's too rare, saves little
|
||||||
|
|
19
src/color.c
19
src/color.c
|
@ -144,24 +144,17 @@ void color_init(void)
|
||||||
bool found_in_list(regexlisttype *head, const char *shibboleth)
|
bool found_in_list(regexlisttype *head, const char *shibboleth)
|
||||||
{
|
{
|
||||||
regexlisttype *item;
|
regexlisttype *item;
|
||||||
bool not_compiled;
|
regex_t rgx;
|
||||||
|
|
||||||
for (item = head; item != NULL; item = item->next) {
|
for (item = head; item != NULL; item = item->next) {
|
||||||
not_compiled = (item->rgx == NULL);
|
regcomp(&rgx, fixbounds(item->full_regex), REG_EXTENDED);
|
||||||
|
|
||||||
if (not_compiled) {
|
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
|
||||||
item->rgx = (regex_t *)nmalloc(sizeof(regex_t));
|
regfree(&rgx);
|
||||||
regcomp(item->rgx, fixbounds(item->full_regex), REG_EXTENDED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regexec(item->rgx, shibboleth, 0, NULL, 0) == 0)
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (not_compiled) {
|
|
||||||
regfree(item->rgx);
|
|
||||||
free(item->rgx);
|
|
||||||
item->rgx = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
regfree(&rgx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue