[2/3] Use strdiff in strcasecmp.
Commit Message
Hi, this optimizes strcasecmp to look for first mismatch which would
likely fail in caseless case. We don't have to handle encoding as
comparison is done bytewise.
Is this ok? Now there isn't performance improvement as strdiff isn't yet
optimized. I will add optimized strdiff in next patch.
* string/strcasecmp.c (__strcasecmp): Use strdiff.
@@ -41,6 +41,10 @@
# define LOCALE_PARAM_DECL
#endif
+#define STRING_TYPE char
+#define USTRING_TYPE unsigned char
+#include <string/strdiff.h>
+
/* Compare S1 and S2, ignoring case, returning less than, equal to or
greater than zero if S1 is lexicographically less than,
equal to or greater than S2. */
@@ -53,12 +57,13 @@ __strcasecmp (s1, s2 LOCALE_PARAM)
#if defined _LIBC && !defined USE_IN_EXTENDED_LOCALE_MODEL
__locale_t loc = _NL_CURRENT_LOCALE;
#endif
+
+ STRDIFF_L (&s1, &s2, __cet_8bit);
+
const unsigned char *p1 = (const unsigned char *) s1;
const unsigned char *p2 = (const unsigned char *) s2;
int result;
- if (p1 == p2)
- return 0;
while ((result = TOLOWER (*p1) - TOLOWER (*p2++)) == 0)
if (*p1++ == '\0')