Hacker News new | past | comments | ask | show | jobs | submit login

That was my first thought. I ran the "slow loop" through the online compiler at:

http://closure-compiler.appspot.com/home

And whether I checked "Simple" or "Advanced" I got:

for(var a = 0;a < arr.length;a++)

So it's not optimizing that pattern yet.




It would have to determine that arr.length doesn't change during the loop. Pretty difficult problem. :)


I'm unsure if the smiley means you're being sarcastic, but if not:

Such determinations are a pretty common thing for an optimizing compiler to attempt:

http://en.wikipedia.org/wiki/Loop-invariant_code_motion




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: