Re: [PATCH] maint: Use logical rather than bitwise operators on bools
From:
Paul Eggert
Subject:
Re: [PATCH] maint: Use logical rather than bitwise operators on bools
Date:
Wed, 23 Sep 2009 15:23:06 -0700
User-agent:
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)
Eric Blake <address@hidden> writes:
>> bool F (bool a, bool b, bool c, bool d) { return a && b && c && d; }
>> bool G (bool a, bool b, bool c, bool d) { return a & b & c & d; }
>
> the compiler should be generating identical code for either choice
> of operator.
Not necessarily, because it could be that the programmer wrote F that
way because its first argument is almost always false, in which case F
is faster even though it's bigger and consumes more instructions in
the worst case.