lib/string.c: simplify stricmp()
Removes 32 bytes on core2 with gcc 4.4.1: text data bss dec hex filename 3196 0 0 3196 c7c lib/string-BEFORE.o 3164 0 0 3164 c5c lib/string-AFTER.o Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Joe Perches <joe@perches.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8a6e25357d
commit
a11d2b64e1
16
lib/string.c
16
lib/string.c
|
@ -36,16 +36,13 @@ int strnicmp(const char *s1, const char *s2, size_t len)
|
||||||
/* Yes, Virginia, it had better be unsigned */
|
/* Yes, Virginia, it had better be unsigned */
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
|
|
||||||
c1 = c2 = 0;
|
if (!len)
|
||||||
if (len) {
|
return 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
c1 = *s1;
|
c1 = *s1++;
|
||||||
c2 = *s2;
|
c2 = *s2++;
|
||||||
s1++;
|
if (!c1 || !c2)
|
||||||
s2++;
|
|
||||||
if (!c1)
|
|
||||||
break;
|
|
||||||
if (!c2)
|
|
||||||
break;
|
break;
|
||||||
if (c1 == c2)
|
if (c1 == c2)
|
||||||
continue;
|
continue;
|
||||||
|
@ -54,7 +51,6 @@ int strnicmp(const char *s1, const char *s2, size_t len)
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
break;
|
break;
|
||||||
} while (--len);
|
} while (--len);
|
||||||
}
|
|
||||||
return (int)c1 - (int)c2;
|
return (int)c1 - (int)c2;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(strnicmp);
|
EXPORT_SYMBOL(strnicmp);
|
||||||
|
|
Loading…
Reference in a new issue