Dan McDonald wrote: > ... > >>ip.c - 17933 - I prefer long winded if() clauses over clever tricks like >>this. Easier to read, easier to debug. Let the compiler worry about >>optimisations like this. >> >> > >That's the rub --> compilers don't do optimizations like this. Read after >the separator line for details, but for now, I'm not going to change this. I >can document it better, but I won't change it. >definitions with -D<foo> to see how the output changes: >... >
My point was that the code is a micro-optimisation, trading readability (and thus maintainability) for a, relatively speaking, small gain in the overall performance. I'd rather see time spent improving overall algorithms than time spent coming up with short cuts like this. But this is just a personal gripe :) Just ask yourself if you want to come back to it in 5 or 10 years and if you'll understand what drugs you were on when you came up with that idea ;) >... > >I wonder if one of us should file a compiler RFE? There is no '^^' operator >in C, but if the compiler can extract common-subexpressions, it *should* be >able to reduce ((a && !b) || (!a && b)) into something resembling (a ^^ b) if >C had such an operator. > > Hmmm...that would make it harder to compile our code with other compilers (ie, gcc.) Darren _______________________________________________ networking-discuss mailing list [email protected]
