On Tue, 14 Jun 2011, Derek M Jones wrote: > Julia, > > > > if (foo) return 1; // or TRUE > > > return 0; // or FALSE > > > > Actually, there are far more of these than I expected. Or at least the > > I'm seeing an order of magnitude more of these than the > return x; return x; pattern, with 1/3 having an else. > > > opposite case, with return 0 under the if. But I'm not sure what the > > improvement would be, unless it is known that foo is already 1, rather > > than some other nonzero integer. One could write return !!foo;, but I'm > > not sure that that is an improvement. And many have fairly complicated > > test expressions. > > Yes, many are surprisingly complicated. > > Perhaps if Greg has more free time he will write an expression > simplifier :-) > Perhaps the first thing to handle at is "x ? 1 : 0" and its negation.
But is it an improvement? julia _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
