Although IE performace is really BAD, computing length each time
isn't a bug.
This property behaves exactly as a method, it's computed each time
the loop is executed. Most of the performance gain is from it, not
from RegExp handling.

Imagine the situation, when loop body removes one element from the
array. It's quite common situation, for example when you operate on
select tag and remove options dynamically in loop body, in each loop
pass. Thus the length of option collection has changed, and the
length must be recalculated.

It seems to me like a Uniform Access Principle done in JavaScript
way :).


> Ok, how do those optimize anything?  Is it some bug in IE? 
> He's just 
> copying a value to a local variable and using that instead
> and there's a big speed difference? 
> What the heck?  I could understand if .length
> were a function, and had to recalculate the value each time,
> but it's just an attribute. 
> That's just odd to me.  I wonder if most of the 
> optimization comes from the RegExp object part.

> Greg



Krzysztof Szafranek
http://szafranek.net

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to