-
Notifications
You must be signed in to change notification settings - Fork 194
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
perf: map filter -> reduce #438
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #438 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 508 506 -2
Branches 136 145 +9
=========================================
- Hits 508 506 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
为啥改这个,记得 PR body 里都写一下原因,以及修改后的效果。 |
return null; | ||
}) | ||
.filter(node => node); | ||
return list.reduce((total, dataNode) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
省一个 filter 是么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是滴,少遍历一次,这里是递归(就不止少遍历一次了)
这个看标题就看出来了呀。map filter 改成 reduce,少遍历一次。然后这里是递归,就不止少遍历一次了。 |
这个标题对不熟悉的人看不出来的,信息量太小了。 |
另外这是一个好习惯,写给自己也写给社区其他人。 |
收到🫡 |
其实对于每层,还是少遍历一次。😈 |
map filter 改成 reduce,少遍历一次。然后这里是递归,就不止少遍历一次了。