4 ms·
The problem is that the code is not semantically identical, there is no way for the compiler to know that nothing else has changed while the loop is executing.
by fleitz 16y ago
The problem is that the code is not semantically identical, there is no way for the compiler to know that nothing else has changed while the loop is executing. It's like the frequent optimization case of
int len = array.length
for(i = 0; i < len; i++){
}
vs.
for(i = 0; i < array.length; i++){
}
The code is semantically different and therefore has a different performance profile.