I've a conditional statement expensive_foo()
which is false in 99.9% cases. And I have a conditional statement bar
which is true in ~50% cases.
And I want some action be done if both statements are true. So I almost certainly know that expensive_foo()
is false and I want to check it only if bar
is true.
Will the code below check the expensive_foo()
ONLY if bar
is true? Or it will check expensive_foo()
every time?
if ( bar && expensive_foo() )
{
...
}
Or I need to make a structure like this:
if ( bar )
{
if ( expensive_foo() )
{
...
}
}