Comparison operator performance (>, >=, <, <=)

后端 未结 4 1379
鱼传尺愫
鱼传尺愫 2020-12-11 15:23

If you were to compare two integers, would the operator have an impact on the time required to perform the comparison? For example, given:

if (x < 60)
         


        
4条回答
  •  借酒劲吻你
    2020-12-11 16:12

    Even if there was noticeable difference, I think compilers are smart enough to care for such things. So my advice is to use what makes the code easier to understand, and leave micro-optimizations to the compiler.

提交回复
热议问题