Which one of these 2 examples would perform better:
Example 1:
if($condition_1)
{
if($condition_2)
{
// do something
}
}
Example 2:
if($condition_1 and $condition_2)
{
// do something
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The difference, if any, will be negligible. You won’t have to worry about the second one evaluating both conditions because of short-circuit evaluation
IMO the 2nd form makes the code more readable. I hate seeing a million indents.