Which is a better practice? (I\'m coding in .Net if that makes a difference)
IF condition = true THEN
...true action--even if rare...
ELSE
...action
E
In the final assembly/machine code, it does make a difference. The statement which is most likely to be executed is done in the path without the branch. This way, the pipeline isn't broken causing valuable cycles to be lost.
I have no clue if the compiler leaves your if then statement order intact and this way forces the assembly to take this optimized route.
I have read that visual studio 2008 (when it was announced) would have an optimization functionality where the compiler adds measurements at branches and then during runtime measures how often a certian path is taken. Then in subsequent recompiles the most optimal code path is preferred.
I have no clue if this feature ever made it past the 'design/academic phase'