Commit a11d2b64 authored by André Goddard Rosa's avatar André Goddard Rosa Committed by Linus Torvalds

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: default avatarAndré Goddard Rosa <andre.goddard@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8a6e2535
...@@ -36,25 +36,21 @@ int strnicmp(const char *s1, const char *s2, size_t len) ...@@ -36,25 +36,21 @@ 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 {
c1 = *s1; do {
c2 = *s2; c1 = *s1++;
s1++; c2 = *s2++;
s2++; if (!c1 || !c2)
if (!c1) break;
break; if (c1 == c2)
if (!c2) continue;
break; c1 = tolower(c1);
if (c1 == c2) c2 = tolower(c2);
continue; if (c1 != c2)
c1 = tolower(c1); break;
c2 = tolower(c2); } while (--len);
if (c1 != c2)
break;
} while (--len);
}
return (int)c1 - (int)c2; return (int)c1 - (int)c2;
} }
EXPORT_SYMBOL(strnicmp); EXPORT_SYMBOL(strnicmp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment