-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tree-view: simplify reducer function #1468
Conversation
I like this, it's a much cleaner solution – @gaearon do we want to merge this? |
If this is a better solution we should search for other uses of Have you verified it runs better in something other than a microbenchmark, and in different browser engines? For example, dispatching a 1000 actions with random indices and measuring the difference with |
|
Performance is not obvious. It must be measured - and not in a On 4 March 2016 at 00:08, Boris Serdiuk notifications@github.com wrote:
|
Performance is never obvious. 😉 |
Can this be considered as a real-world benchmark: https://gist.github.com/just-boris/6375c63bd8f334170511? |
Does it also work better with smaller data sets (e.g. < 100)? |
@gaearon Added results on various sizes in the gist. The advantage is not big, but filter is still better. |
Can you also check SpiderMonkey (Firefox) please? |
Done. Still faster.
All results are still availabe in the gist |
tree-view: simplify reducer function
👍 Thanks for researching this thoroughly! |
Would you please look for |
@just-boris Well done! The results are fairly conclusive. Not so much of an advantage for small arrays. Even so, the filter version is actually easier to read. |
Ha-ha, optimization of browsers moves on =) |
Spread operator is really not necessary here. It can be replaced with a simple filter function. Fortunately
.filter()
returns new array instance as it required by Redux and here it has a perfect fit.Even more, filter works here faster: because doesn't create temporary arrays.