Why is this code with several “or” statements slightly faster than using a lookup table in Java?

后端 未结 5 2393
旧时难觅i
旧时难觅i 2021-02-20 17:30

While looking at a micro-optimization question that I asked yesterday (here), I found something strange: an or statement in Java is running slightly faste

5条回答
  •  [愿得一人]
    2021-02-20 17:59

    According to this article accessing array elements are "2 or 3 times as expensive as accessing non-array elements". Your test shows that the difference may be even bigger.

提交回复
热议问题