Is < faster than <=?

后端 未结 14 1086
孤城傲影
孤城傲影 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:13

    Maybe the author of that unnamed book has read that a > 0 runs faster than a >= 1 and thinks that is true universally.

    But it is because a 0 is involved (because CMP can, depending on the architecture, replaced e.g. with OR) and not because of the <.

提交回复
热议问题