Performance: greater / smaller than vs not equal to

前端 未结 7 1594
礼貌的吻别
礼貌的吻别 2020-12-14 14:47

I wonder if there is a difference in performance between

checking if a value is greater / smaller than another

for(int x = 0; x <         


        
7条回答
  •  臣服心动
    2020-12-14 15:24

    There is rarely a performance hit but the first is much more reliable as it will handle both of the extraordinary cases where

    1. y < 0 to start
    2. x or y are messed with inside the block.

提交回复
热议问题