Also:
Can someone explain to me why it has to assume that arr.length could change? It states it does, but I don't see why. That seems like a pretty obvious optimization flaw: you should be able to safely assume that something won't change if the only cases where it could change is if it already has changed. In other words, why is this:
var sum = 0;
for (var i = 0, L = arr.length;
i < arr.length;
++i) {
if (arr.length !== L)
H.throwConcurrentModificationError(arr);
var item = list[i];
sum += item;
}
not optimizable to remove the whole business with L and the if check?Also, this is one of my frustrations with optimizers in general. Far too many of them end up with global (or at the very least) side-effects of trivial changes (or worse, changes that shouldn't do anything!), to the point of making optimization a fool's game. (I optimized this method, but now the change in function alignment changes cache aliasing such that the program runs slower. Hey look: A runs substantially faster than B. But if you add a comment here, B runs faster than A.)