Quantcast
Channel: Two if conditions or one if with OR - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Two if conditions or one if with OR

$
0
0

I have a small doubt

I have following code

bool res= false;if(cond1){   res = true;}if(cond2){   res = true;}

Instead of this if I put following code

if(cond1 || cond2){   res = true;}

Which code snippet will be more optimized?

I believe it would be second one as I have avoided an If condition.


Viewing all articles
Browse latest Browse all 10

Trending Articles