From be13f7bff66e1850f9057dd813d6e7be022d9516 Mon Sep 17 00:00:00 2001 From: Liubov Dmitrieva Date: Sat, 15 Oct 2011 11:10:08 -0400 Subject: Optimized memcmp and wmemcmp for x86-64 and x86-32 --- wcsmbs/wmemcmp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'wcsmbs/wmemcmp.c') diff --git a/wcsmbs/wmemcmp.c b/wcsmbs/wmemcmp.c index c6a321b..e7edc87 100644 --- a/wcsmbs/wmemcmp.c +++ b/wcsmbs/wmemcmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997i, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -19,9 +19,12 @@ #include +#ifndef WMEMCMP +# define wmemcmp +#endif int -wmemcmp (s1, s2, n) +WMEMCMP (s1, s2, n) const wchar_t *s1; const wchar_t *s2; size_t n; @@ -34,19 +37,19 @@ wmemcmp (s1, s2, n) c1 = (wint_t) s1[0]; c2 = (wint_t) s2[0]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; c1 = (wint_t) s1[1]; c2 = (wint_t) s2[1]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; c1 = (wint_t) s1[2]; c2 = (wint_t) s2[2]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; c1 = (wint_t) s1[3]; c2 = (wint_t) s2[3]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; s1 += 4; s2 += 4; n -= 4; @@ -57,7 +60,7 @@ wmemcmp (s1, s2, n) c1 = (wint_t) s1[0]; c2 = (wint_t) s2[0]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; ++s1; ++s2; --n; @@ -67,7 +70,7 @@ wmemcmp (s1, s2, n) c1 = (wint_t) s1[0]; c2 = (wint_t) s2[0]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; ++s1; ++s2; --n; @@ -77,7 +80,7 @@ wmemcmp (s1, s2, n) c1 = (wint_t) s1[0]; c2 = (wint_t) s2[0]; if (c1 - c2 != 0) - return c1 - c2; + return c1 > c2 ? 1 : -1; } return 0; -- cgit v1.1