Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Nov 2011 06:46:18 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        David Chisnall <theraven@FreeBSD.org>
Cc:        src-committers@FreeBSD.org, Eitan Adler <eadler@FreeBSD.org>, svn-src-all@FreeBSD.org, dim@FreeBSD.org, Brooks Davis <brooks@FreeBSD.org>, bde@FreeBSD.org, svn-src-head@FreeBSD.org, David Schultz <das@FreeBSD.org>
Subject:   Re: svn commit: r227812 - head/lib/libc/string
Message-ID:  <86vcq4er4l.fsf@ds4.des.no>
In-Reply-To: <0DC88C34-91B4-49D1-AA8A-73B14C99D35B@FreeBSD.org> (David Chisnall's message of "Wed, 23 Nov 2011 10:37:14 %2B0000")
References:  <201111220250.pAM2oPWC070856@svn.freebsd.org> <20111122153332.GA20145@zim.MIT.EDU> <CAF6rxgmPeZCZ3c0xbd-4riqvLHob8U9eWG25R8P6FG2BjTfyyA@mail.gmail.com> <20111122202735.GA21442@zim.MIT.EDU> <0DC88C34-91B4-49D1-AA8A-73B14C99D35B@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
David Chisnall <theraven@FreeBSD.org> writes:
> As to the | vs || issue - by all means change it to || if it fits
> better with the FreeBSD style.  In the general case I prefer to use |
> to hint to the compiler and readers of the code that short-circuit
> evaluation is not required and to remove a sequence point and make
> life easier for the optimiser.

The optimizer is smarter than you think, although it can sometimes get
confused when programmers start talking about what they want the
optimizer to do instead of what they want the program to do.

> In this case, the two are equivalent so it's just a hint to the
> reader, and apparently (judging by the responses so far) one that is
> not well understood.

The reader doesn't need a hint to understand what (n =3D=3D 0 || s1 =3D=3D =
s2)
means.  The reader will however need a couple of seconds to understand
what ((n =3D=3D 0) | (s1 =3D=3D s2)) means, and will waste a few more wonde=
ring
why the programmer didn't pick the more obvious solution.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86vcq4er4l.fsf>