RFC: small syscons and kbd patch

Nate Eldredge neldredge at math.ucsd.edu
Fri Dec 5 11:12:28 PST 2008


On Fri, 5 Dec 2008, Stephen Montgomery-Smith wrote:

> Nate Eldredge wrote:
>
>> int bangbang(int x) { return !!x; }
>> int ternary(int x) { return x ? 1 : 0; }
>
> Stylewise, I prefer
>
> int notzero(int x) { return x!=0; }

icc -O0 compiles notzero the same as bangbang (better than ternary).  tcc 
produces better code for notzero than the other two.  Sun cc without 
optimization produces slightly better code for notzero than the other two 
(one jump instead of two).  For everything else all three produce 
equivalent code.

`x && 1' and `x || 0' are some other possibilities.

Anyway, maybe there is something more useful we could all be doing. :)

-- 

Nate Eldredge
neldredge at math.ucsd.edu


More information about the freebsd-hackers mailing list