diff options
author | Paul Smith <psmith@gnu.org> | 2013-06-22 00:22:08 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-06-22 00:22:08 -0400 |
commit | cc85b927cdc1a4dad3217842215903a45044fc43 (patch) | |
tree | 74ae34c9306f5dde33e258c4181215ee04d4203f /misc.c | |
parent | bee4d93a591f7f729717f6079f7d62ef555d9887 (diff) | |
download | gunmake-cc85b927cdc1a4dad3217842215903a45044fc43.tar.gz |
Create a character map to use for locating stop-points in strings.
In various places we were passing flags and characters to compare, then
using complex conditionals to see where to stop in string searches.
Performance numbers reveal that we were spending as much as 23% of our
processing time in these functions, most of it in the comparison lines.
Instead create a character map and use a single bitwise comparison to
determine if this is any one of the stop characters.
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 32 |
1 files changed, 1 insertions, 31 deletions
@@ -483,41 +483,11 @@ lindex (const char *s, const char *limit, int c) char * end_of_token (const char *s) { - while (*s != '\0' && !isblank ((unsigned char)*s)) + while (! STOP_SET (*s, MAP_BLANK|MAP_NUL)) ++s; return (char *)s; } -#ifdef WINDOWS32 -/* - * Same as end_of_token, but take into account a stop character - */ -char * -end_of_token_w32 (const char *s, char stopchar) -{ - const char *p = s; - int backslash = 0; - - while (*p != '\0' && *p != stopchar - && (backslash || !isblank ((unsigned char)*p))) - { - if (*p++ == '\\') - { - backslash = !backslash; - while (*p == '\\') - { - backslash = !backslash; - ++p; - } - } - else - backslash = 0; - } - - return (char *)p; -} -#endif - /* Return the address of the first nonwhitespace or null in the string S. */ char * |