|
From: <sv...@va...> - 2012-07-26 22:44:14
|
philippe 2012-07-26 23:44:07 +0100 (Thu, 26 Jul 2012)
New Revision: 12790
Log:
micro-optimisation in m_libcbase.c cmp functions
Modified files:
trunk/coregrind/m_libcbase.c
Modified: trunk/coregrind/m_libcbase.c (+12 -16)
===================================================================
--- trunk/coregrind/m_libcbase.c 2012-07-26 22:37:36 +01:00 (rev 12789)
+++ trunk/coregrind/m_libcbase.c 2012-07-26 23:44:07 +01:00 (rev 12790)
@@ -303,13 +303,12 @@
Int VG_(strcmp) ( const Char* s1, const Char* s2 )
{
while (True) {
- if (*s1 == 0 && *s2 == 0) return 0;
- if (*s1 == 0) return -1;
- if (*s2 == 0) return 1;
-
if (*(UChar*)s1 < *(UChar*)s2) return -1;
if (*(UChar*)s1 > *(UChar*)s2) return 1;
+ /* *s1 == *s2 */
+ if (*s1 == 0) return 0;
+
s1++; s2++;
}
}
@@ -319,12 +318,11 @@
while (True) {
UChar c1 = (UChar)VG_(tolower)(*s1);
UChar c2 = (UChar)VG_(tolower)(*s2);
- if (c1 == 0 && c2 == 0) return 0;
- if (c1 == 0) return -1;
- if (c2 == 0) return 1;
-
if (c1 < c2) return -1;
if (c1 > c2) return 1;
+
+ /* c1 == c2 */
+ if (c1 == 0) return 0;
s1++; s2++;
}
@@ -335,12 +333,11 @@
SizeT n = 0;
while (True) {
if (n >= nmax) return 0;
- if (*s1 == 0 && *s2 == 0) return 0;
- if (*s1 == 0) return -1;
- if (*s2 == 0) return 1;
-
if (*(UChar*)s1 < *(UChar*)s2) return -1;
if (*(UChar*)s1 > *(UChar*)s2) return 1;
+
+ /* *s1 == *s2 */
+ if (*s1 == 0) return 0;
s1++; s2++; n++;
}
@@ -355,13 +352,12 @@
if (n >= nmax) return 0;
c1 = (UChar)VG_(tolower)(*s1);
c2 = (UChar)VG_(tolower)(*s2);
- if (c1 == 0 && c2 == 0) return 0;
- if (c1 == 0) return -1;
- if (c2 == 0) return 1;
-
if (c1 < c2) return -1;
if (c1 > c2) return 1;
+ /* c1 == c2 */
+ if (c1 == 0) return 0;
+
s1++; s2++; n++;
}
}
|