Why is order of expressions in if statement important

后端 未结 9 2081
无人共我
无人共我 2021-01-05 03:01

Suppose I have an IF condition :

if (A || B) 
    ∧
    |
    |
   left
{ 
   // do something  
}

Now suppose that A

9条回答
  •  我在风中等你
    2021-01-05 03:52

    Yes exactly, you're gaining runtime, it won't seem much for one operation, but you have to keep in mind that operations will get repeated millions of times

    Why perform two evaluations when one is enough is the logic

提交回复
热议问题