@Zuka - True... however for prefetch optimizations, you should tailor your if statements so the most frequent "condition" happens first in the if block. So...
if(MyBool){
Works fine... it is easier... but if
MyBool is usually
false, you might want to get in the habit of checking it for
false first or changing the boolean's "name" and definition so you're "trues" are always the more common condition and placing them first works.
This is why we get into the
if(!Bool) situation... and for readability we talk of
if(MyBool == false) for ease of reading but furthering it with Lilith's recommendation of
if(false==MyBool) to prevent accidently assigning a value during the test due to a typo. This is the only way I know of in C++ to really catch that in manner allowing you to verify if its what you wanted to
true or not ( I made a boolean funny
)
Trust me I'm all for easier... and frankly - what's a clock cycle or two in a prefetch cache? Bleech.. BUT... these habits over time (throughout thousands of lines of code) add up to a gain that is hard to go back and rectify later if you didn't do it from the start. Turns out for me its easier and faster in the long run (code wise and code editing) to do it this way:
if( MyBool ) or
if(false==MyBool)
--Jason
[edited some err's]