>>1
if
fun doesn't have any side effects, they are equivalent and should be compiled to the same code. if
fun does have side effects, it doesn't matter which is faster, you have to choose which one to do based on whether you always need those side effects or only need them when
a > 3.
you might be able to do better, tho, if you don't need to use
expected_b later and either
fun or
good_enough doesn't have side effects...
if only
good_enough has side effects:
if(a > 3 && good_enough(b, fun(a)) do_stuff();
if only
fun has side effects:
if(good_enough(b, fun(a)) && a < 3) do_stuff();
if both of them have side effects, you might be able to do better or you might not, depending on exactly what it is you're trying to do.