Java compilers are very poor at lifting constant expressions out of loops. The C/Java for loop is a bad abstraction, because it encourages re-computation of the end value in the most typical case. So for(int i=0; i<str.length(); i++) is three times slower than int len = str.length(); for(int i=0; i<len; i++)
Does anyone know if this is still valid advice? I recall reading somewhere that the JIT has optimized around this problem.
Does anyone know if this is still valid advice? I recall reading somewhere that the JIT has optimized around this problem.