Messages in this thread | | | Date | Fri, 18 Sep 1998 15:54:53 +0300 (EET DST) | From | Jukka Tapani Santala <> | Subject | Re: Non-urgent issue with fs/isofs/util.c |
| |
On Fri, 18 Sep 1998, Helge Hafting wrote: > The equivalent code > if (!((year+2) & 3) && month > 2 && year != 130) is probably > faster. The somewhat expensive mod operator is > replaced by a bitwise "and", that is faster on most platforms.
While GCC optimizer automatically does this (since the value is a constant known at compile-time), it may still be worth doing as it essentially reduces one "phase" in optimizer, speeding compilation up just slightly (Though doubt it you'd notice unless every line in code did that;) and letting the other optimization phases to work on the already optimized code (Altough, again, the passes have been tried to arrange in such an order that later passes depend only on earlier changes, if you get what I mean).
Also, for somebody debugging the code it will be easier to have the source match the binary (Even if it's easy to make that conversion in mind and probably no surprise to most). In short, it probably doesn't matter, but I think it's still good coding practice to optimize the source-code already where possible without damaging the code readability - somebody might disagree saying they find %4 more readable than &3, but I think understanding the equivalence should be prerequisites to kernel work.
-Donwulff
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |