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

Answer by Mike Dunlavey for Two if conditions or one if with OR

$
0
0

Assuming each cond is about equally likely to be true as false, and assuming each cond takes one STU (significant time unit) then half the time the || will take 1 STU and half the time 2 STU, for overall expectation of 1.5 STU instead of 2.

If STU is a nanosecond, it probably doesn't matter.

If STU is a century, it probably does.


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>