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

后端 未结 4 1377
鱼传尺愫
鱼传尺愫 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:11

    There is almost certainly no difference in performance. For CISC processors, you'll typically have all manner of branch instructions that cope with all the difference < <= > >= etc. On RISC there may be a very small performance difference although I'd seriously doubt it!

提交回复
热议问题