Performance: greater / smaller than vs not equal to

前端 未结 7 1597
礼貌的吻别
礼貌的吻别 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:27

    You should still do what is clearer, safer and easier to understand. These micro-tuning discussions are usually a waste of your time because

    • they rarely make a measurable difference
    • when they make a difference this can change if you use a different JVM, or processor. i.e. without warning.

    Note: the machine generated can also change with processor or JVM, so looking this is not very helpful in most cases, even if you are very familiar with assembly code.

    What is much, much more important is the maintainability of the software.

提交回复
热议问题