diff options
Diffstat (limited to 'benchtests/bench-strncmp.c')
-rw-r--r-- | benchtests/bench-strncmp.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/benchtests/bench-strncmp.c b/benchtests/bench-strncmp.c index 750150c..a4f3412 100644 --- a/benchtests/bench-strncmp.c +++ b/benchtests/bench-strncmp.c @@ -28,7 +28,6 @@ #ifdef WIDE # define L(str) L##str # define SIMPLE_STRNCMP simple_wcsncmp -# define STUPID_STRNCMP stupid_wcsncmp /* Wcsncmp uses signed semantics for comparison, not unsigned. Avoid using substraction since possible overflow. */ @@ -47,29 +46,9 @@ simple_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) return 0; } -int -stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) -{ - wchar_t c1, c2; - size_t ns1 = wcsnlen (s1, n) + 1, ns2 = wcsnlen (s2, n) + 1; - - n = ns1 < n ? ns1 : n; - n = ns2 < n ? ns2 : n; - - while (n--) - { - c1 = *s1++; - c2 = *s2++; - if (c1 != c2) - return c1 > c2 ? 1 : -1; - } - return 0; -} - #else # define L(str) str # define SIMPLE_STRNCMP simple_strncmp -# define STUPID_STRNCMP stupid_strncmp /* Strncmp uses unsigned semantics for comparison. */ int @@ -82,23 +61,10 @@ simple_strncmp (const char *s1, const char *s2, size_t n) return ret; } -int -stupid_strncmp (const char *s1, const char *s2, size_t n) -{ - size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1; - int ret = 0; - - n = ns1 < n ? ns1 : n; - n = ns2 < n ? ns2 : n; - while (n-- && (ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) == 0); - return ret; -} - #endif /* !WIDE */ typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); -IMPL (STUPID_STRNCMP, 0) IMPL (SIMPLE_STRNCMP, 0) IMPL (STRNCMP, 1) |