Which is more expensive multiple conditional branches or multiple relational expression in a single condition?
- by bman
Which is more expensive in terms of processing costs
if ( x < 20 && z == "M") {
// statements 3
}
if ( x >= 20 && w && x <= 65) {
// statements 1
}
if( x >= 20 &&z != "M"){
// statements 2
}
or this
if ( x < 20 ) {
if( z == 'M') // statements 3;
} else
if ( x <= 65 && w == true ) // statements 1;
if ( z == 'F' ) // statements 2;
}