During a change in a source code, I came across the following situation, developed by another developer:
if ( booleano1 || booleano2 || booleano3 )
{
if( booleano1 )
{
//faz algo
}
if( booleano2 )
{
//faz algo
}
if( booleano3 )
{
//faz algo
}
}
Clearly, the developer's intention was to verify that one of the conditions was true before performing the 3 if
separately. The only justification I could find to have been implemented in this way would be a (insignificant?) Gain in performance. So, my question is: is there any performance improvement by using multiple conditions on the same if
compared to implementing multiple if
separately?