From: Paolo Bonzini Date: Fri, 11 Aug 2017 11:44:31 +0000 (+0200) Subject: Remove MAP_PERCENT as strchr is faster. X-Git-Tag: 4.2.90~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98602961981b6cc38fe20d067767d1aa25e124b8;p=thirdparty%2Fmake.git 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. --- diff --git a/main.c b/main.c index 95ebc308..5e0b7aa6 100644 --- a/main.c +++ b/main.c @@ -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; diff --git a/makeint.h b/makeint.h index c79d0b49..d71c043e 100644 --- a/makeint.h +++ b/makeint.h @@ -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 diff --git a/read.c b/read.c index a5974881..2cd497a4 100644 --- a/read.c +++ b/read.c @@ -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