diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-09-13 22:57:26 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-09-14 20:53:52 -0700 |
commit | 702801fa857a5de60911cbe3440dc949d060b448 (patch) | |
tree | 2f06f8f8f54fdb0c917ff683f9e95fee2f206b75 /match.c | |
parent | 5ea3d1dab234678ba2bb3076bfa3f0dfab6d8cd6 (diff) |
Improve performance of has_match
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -9,10 +9,14 @@ int has_match(const char *needle, const char *haystack){ while(*needle){ - if(!*haystack) - return 0; - while(*haystack && tolower(*needle) == tolower(*haystack++)) - needle++; + char nch = tolower(*needle++); + for(;;){ + char ch = *haystack++; + if(!ch) + return 0; + else if(nch == tolower(ch)) + break; + } } return 1; } |