mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
8a36f0bad4
commit
64c0cfb0bd
1 changed files with 10 additions and 10 deletions
|
@ -14,15 +14,15 @@ int strcasecmp(const char *s1, const char *s2)
|
||||||
|
|
||||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
{
|
{
|
||||||
if(!n)
|
int d = 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
while (n-- != 0 && tolower(*s1) == tolower(*s2)) {
|
for(; n != 0; n--)
|
||||||
if(n == 0 || *s1 == '\0')
|
{
|
||||||
|
int c1 = tolower(*s1++);
|
||||||
|
int c2 = tolower(*s2++);
|
||||||
|
if((d = c1 - c2) != 0 || c2 == '\0')
|
||||||
break;
|
break;
|
||||||
s1++;
|
|
||||||
s2++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
|
return d;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue