Is it faster to access final local variables than class variables in Java?

前端 未结 5 1786
闹比i
闹比i 2020-12-06 01:07

I\'ve been looking at at some of the java primitive collections (trove, fastutil, hppc) and I\'ve noticed a pattern that class variables are sometimes declared as fina

5条回答
  •  星月不相逢
    2020-12-06 02:00

    Such simple optimizations are already included in JVM runtime. If JVM does naive access to instance variables, our Java applications will be turtle slow.

    Such manual tuning probably worthwhile for simpler JVMs though, e.g. Android.

提交回复
热议问题