summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-09-13 22:57:26 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-09-14 20:53:52 -0700
commit702801fa857a5de60911cbe3440dc949d060b448 (patch)
tree2f06f8f8f54fdb0c917ff683f9e95fee2f206b75 /match.c
parent5ea3d1dab234678ba2bb3076bfa3f0dfab6d8cd6 (diff)
Improve performance of has_match
Diffstat (limited to 'match.c')
-rw-r--r--match.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/match.c b/match.c
index f55f954..26151db 100644
--- a/match.c
+++ b/match.c
@@ -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;
}