Replace _.each and for-in with for loop in hot paths#432
Replace _.each and for-in with for loop in hot paths#432sebmck merged 3 commits intobabel:masterfrom
Conversation
|
With second commit, 29% improvement over master (150ms instead of 212ms). |
|
👍 looks good |
There was a problem hiding this comment.
I'm not sure if it makes a difference, but does caching the length here help? i.e. for (var i = 0, length = str.length; i < length; i++) {
There was a problem hiding this comment.
No, it doesn't appear so. I ran it and it's the same speed.
I remember reading V8 does that optimization by itself.
There was a problem hiding this comment.
AFAIK caching built-in length won't make big difference in modern JS engine like V8. See: http://mrale.ph/blog/2014/12/24/array-length-caching.html
|
👍 |
|
I added a few minor impovements: gaearon@5783973 In my testing, they shave off about 5-10ms from my benchmark. I'm afraid I can't find other low-hanging optimization fruit other than this and #433 so I'll be glad if people smarter than me continued with this. :-) |
|
👍 |
Replace _.each and for-in with for loop in hot paths
|
Awesome, thanks for this! |
* chore(package): update eslint-config-babel to version 6.0.0 Closes #432 https://greenkeeper.io/ * Fix linting
This is my first PR extracted from experiments in #428.
This alone gives me 24% time improvement (from 212ms on my benchmark to 160ms).