Is < faster than <=?

后端 未结 14 816
孤城傲影
孤城傲影 2020-11-22 13:43

Is if( a < 901 ) faster than if( a <= 900 ).

Not exactly as in this simple example, but there are slight performance changes on loop

14条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 14:02

    This would be highly dependent on the underlying architecture that the C is compiled to. Some processors and architectures might have explicit instructions for equal to, or less than and equal to, which execute in different numbers of cycles.

    That would be pretty unusual though, as the compiler could work around it, making it irrelevant.

提交回复
热议问题