mardi 27 avril 2021

Nested if statments or long one liners? C++

Guys which of the following is quickest?

This:

if ( (t > tmin.at(j) && (t < tmax.at(j)  || tmax.at(j) < 0 )) )
            {
               return j;
               break;
            }

This:

if ( (t > tmin.at(j) )
     if( t < tmax.at(j)  || tmax.at(j) < 0 ) 
            {
               return j;
               break;
            }

or will they compile to the exact same thing?

Just a fairly standard search through some vectors to find the index of our value but wondering whether nested if statments is quicker or having it all in one line is better? Couldn't find anything online for this question...

Thanks!

Aucun commentaire:

Enregistrer un commentaire