bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: Use logical rather than bitwise operators on bools


From: Pádraig Brady
Subject: Re: [PATCH] maint: Use logical rather than bitwise operators on bools
Date: Thu, 24 Sep 2009 08:29:06 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071008)

Paul Eggert wrote:
> Pádraig Brady <address@hidden> writes:
> 
>> I did also check the speed with a test program
>> (attached) which showed the logical test was a bit faster on my pentium-m.
>> Note I compiled without optimization
> 
> I would expect optimization would be crucial: I got the 60% increase
> in number of instructions for && when compiling with optimization, and
> without optimization there was almost no difference between && and &.

Well I posted the sizes for the default compile (-O2)
which  shows a net size reduction of 208 bytes from the
total size of all programs.

> Although I admit that it bugs me that the change makes the code slower
> and fatter, my primary objection is that short-circuit AND has more
> complicated semantics than Boolean AND, and we shouldn't necessarily
> favor the former over the latter.

TBH I don't find this. I find the logical operations a higher
level thing that's easier for me to comprehend at least,
and possibly for (future) compilers also.

> I agree that the bitwise part of
> the logical AND in traditional C 'int' semantics is a problem, but to
> my mind it's not a problem that necessarily overwhelms the
> short-circuit disadvantage.

Yep that's a side issue on older compilers.

cheers,
Pádraig.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]