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 == 0 || s1 == s2)
means. The reader will however need a couple of seconds to understand
what ((n == 0) | (s1 == s2)) means, and will waste a few more wondering
why the programmer didn't pick the more obvious solution.
Dag-Erling Smrgrav - email@example.com