diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2010-02-07 00:37:47 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2010-02-07 00:37:47 +0000 |
commit | 64c0cfb0bda0a9d75be6965c2defadfa28c429c9 (patch) | |
tree | 074cdd30076542e2c62d92ca6bf7828db483fefc /firmware/common | |
parent | 8a36f0bad4846b9e7d49b2c598c23c0443c2d1b5 (diff) |
Optimize (size and speed) strncasecmp (based on a newlib patch).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24542 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/strcasecmp.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/firmware/common/strcasecmp.c b/firmware/common/strcasecmp.c index 7bd0d61dd5..b9dd6c13c4 100644 --- a/firmware/common/strcasecmp.c +++ b/firmware/common/strcasecmp.c @@ -14,15 +14,15 @@ int strcasecmp(const char *s1, const char *s2) int strncasecmp(const char *s1, const char *s2, size_t n) { - if(!n) - return 0; - - while (n-- != 0 && tolower(*s1) == tolower(*s2)) { - if(n == 0 || *s1 == '\0') - break; - s1++; - s2++; + int d = 0; + + for(; n != 0; n--) + { + int c1 = tolower(*s1++); + int c2 = tolower(*s2++); + if((d = c1 - c2) != 0 || c2 == '\0') + break; } - - return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); + + return d; } |