Remove MAP_PERCENT as strchr is faster.

* read.c (find_percent_cached): Use strchr instead of STOP_SET
to find % or nul.
* makeint.h (MAP_PERCENT): Remove.
* main.c (initialize_stopchar_map): Remove.
This commit is contained in:
Paolo Bonzini 2017-08-11 13:44:31 +02:00 committed by Paul Smith
parent 4fd56724ad
commit 9860296198
3 changed files with 5 additions and 7 deletions

1
main.c
View file

@ -632,7 +632,6 @@ initialize_stopchar_map (void)
stopchar_map[(int)';'] = MAP_SEMI;
stopchar_map[(int)'='] = MAP_EQUALS;
stopchar_map[(int)':'] = MAP_COLON;
stopchar_map[(int)'%'] = MAP_PERCENT;
stopchar_map[(int)'|'] = MAP_PIPE;
stopchar_map[(int)'.'] = MAP_DOT | MAP_USERFUNC;
stopchar_map[(int)','] = MAP_COMMA;

View file

@ -397,7 +397,6 @@ extern int unixy_shell;
#define MAP_SEMI 0x0010
#define MAP_EQUALS 0x0020
#define MAP_COLON 0x0040
#define MAP_PERCENT 0x0080
#define MAP_PIPE 0x0100
#define MAP_DOT 0x0200
#define MAP_COMMA 0x0400

10
read.c
View file

@ -2429,10 +2429,9 @@ find_percent_cached (const char **string)
while (1)
{
while (! STOP_SET (*p, MAP_PERCENT|MAP_NUL))
++p;
p = strchr(p, '%');
if (*p == '\0')
if (!p)
break;
/* See if this % is escaped with a backslash; if not we're done. */
@ -2478,11 +2477,12 @@ find_percent_cached (const char **string)
if (new)
{
*string = strcache_add (*string);
p = *string + (p - new);
if (p)
p = *string + (p - new);
}
/* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
return (*p == '\0') ? NULL : p;
return p;
}
/* Find the next line of text in an eval buffer, combining continuation lines