I have an if statement with two conditions (separated by an OR operator), one of the conditions covers + 70% of situations and takes much less time to process / execute than the second condition, so in the interest of speed I want only the second condition for processing if the first the condition is evaluated as false.
if I arrange the conditions so that the first condition (faster) appears in the if statement first - in cases where this condition is satisfied and evaluated as true, will the second condition be processed at all?
if ( (condition1) | (condition2) ){
// do this
}
or would I need to nest two if statements to check only the second condition, if the first is evaluated as false?
if (condition1){
// do this
}else if (condition2){
// do this
}
I work in PHP, however I assume that this may not be language dependent.