summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2011-11-22 02:50:24 +0000
committereadler <eadler@FreeBSD.org>2011-11-22 02:50:24 +0000
commit0b82f36a9ca5d1ec455633a57e2d996699726fbc (patch)
treed0183307647305a17d5a3a417440394fcc28d219 /lib
parentb0d439f34e326dd61912033a3a61bff5d4a88be6 (diff)
downloadFreeBSD-src-0b82f36a9ca5d1ec455633a57e2d996699726fbc.zip
FreeBSD-src-0b82f36a9ca5d1ec455633a57e2d996699726fbc.tar.gz
- fix some style(9) nits with my last commit
- add a comment explaining why I used '|' instead of '||' Submitted by: danfe@ Approved by: emaste@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/string/strcasecmp.c7
-rw-r--r--lib/libc/string/strncmp.c1
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c
index dae91d3..582399d 100644
--- a/lib/libc/string/strcasecmp.c
+++ b/lib/libc/string/strcasecmp.c
@@ -49,7 +49,7 @@ strcasecmp_l(const char *s1, const char *s2, locale_t locale)
*us1 = (const u_char *)s1,
*us2 = (const u_char *)s2;
if (s1 == s2)
- return (0);
+ return (0);
FIX_LOCALE(locale);
@@ -73,8 +73,9 @@ strncasecmp_l(const char *s1, const char *s2, size_t n, locale_t locale)
*us1 = (const u_char *)s1,
*us2 = (const u_char *)s2;
- if (( s1 == s2) | (n == 0))
- return (0);
+ /* use a bitwise or to avoid an additional branch instruction */
+ if ((s1 == s2) | (n == 0))
+ return (0);
do {
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c
index 46db3f9..8da2c43 100644
--- a/lib/libc/string/strncmp.c
+++ b/lib/libc/string/strncmp.c
@@ -39,6 +39,7 @@ int
strncmp(const char *s1, const char *s2, size_t n)
{
+ /* use a bitwise or to avoid an additional branch instruction */
if ((n == 0) | (s1 == s2))
return (0);
OpenPOWER on IntegriCloud