Date: Mon, 21 Nov 2011 22:45:36 -0800 From: mdf@FreeBSD.org To: Eitan Adler <eadler@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r227812 - head/lib/libc/string Message-ID: <CAMBSHm8HfW-XTSk9zQda4vDmbrzyEG_vnydb5JZyHaNh2rF4gw@mail.gmail.com> In-Reply-To: <201111220250.pAM2oPWC070856@svn.freebsd.org> References: <201111220250.pAM2oPWC070856@svn.freebsd.org>
index | next in thread | previous in thread | raw e-mail
On Mon, Nov 21, 2011 at 6:50 PM, Eitan Adler <eadler@freebsd.org> wrote: > Author: eadler (ports committer) > Date: Tue Nov 22 02:50:24 2011 > New Revision: 227812 > URL: http://svn.freebsd.org/changeset/base/227812 > > Log: > - fix some style(9) nits with my last commit > - add a comment explaining why I used '|' instead of '||' > > Submitted by: danfe@ > Approved by: emaste@ > > Modified: > head/lib/libc/string/strcasecmp.c > head/lib/libc/string/strncmp.c > > Modified: head/lib/libc/string/strcasecmp.c > ============================================================================== > --- head/lib/libc/string/strcasecmp.c Tue Nov 22 02:27:59 2011 (r227811) > +++ head/lib/libc/string/strcasecmp.c Tue Nov 22 02:50:24 2011 (r227812) > @@ -49,7 +49,7 @@ strcasecmp_l(const char *s1, const char > *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 > *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); I guess I'm a little confused. Do we really have profiling information at this level that suggests the overhead of the branch is significant? I thought most hardware had pretty good branch-prediction, particularly with speculative execution. Wouldn't something like __predict_false() have more value for performance, or is all this just guess-work? I would much rather have the code say what it means unless there's real, measurable performance differences from doing otherwise. Thanks, matthewhelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm8HfW-XTSk9zQda4vDmbrzyEG_vnydb5JZyHaNh2rF4gw>
