Skip to content
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

Merged
merged 1 commit into from
Aug 4, 2023
Merged

Conversation

linxianxi
Copy link
Contributor

@linxianxi linxianxi commented Aug 4, 2023

map filter 改成 reduce,少遍历一次。然后这里是递归,就不止少遍历一次了。

@vercel
Copy link

vercel bot commented Aug 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tree-select ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 4, 2023 9:22am

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Merging #438 (30244ea) into master (ac7205f) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 30244ea differs from pull request most recent head a95cd97. Consider uploading reports for the commit a95cd97 to get more accurate results

@@            Coverage Diff            @@
##            master      #438   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines          508       506    -2     
  Branches       136       145    +9     
=========================================
- Hits           508       506    -2     
Files Changed Coverage Δ
src/hooks/useFilterTreeData.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@afc163
Copy link
Member

afc163 commented Aug 4, 2023

为啥改这个,记得 PR body 里都写一下原因,以及修改后的效果。

return null;
})
.filter(node => node);
return list.reduce((total, dataNode) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

省一个 filter 是么?

Copy link
Contributor Author

@linxianxi linxianxi Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是滴,少遍历一次,这里是递归(就不止少遍历一次了)

@linxianxi
Copy link
Contributor Author

为啥改这个,记得 PR body 里都写一下原因,以及修改后的效果。

这个看标题就看出来了呀。map filter 改成 reduce,少遍历一次。然后这里是递归,就不止少遍历一次了。

@linxianxi linxianxi requested a review from zombieJ August 4, 2023 09:49
@afc163
Copy link
Member

afc163 commented Aug 4, 2023

这个标题对不熟悉的人看不出来的,信息量太小了。

@afc163
Copy link
Member

afc163 commented Aug 4, 2023

另外这是一个好习惯,写给自己也写给社区其他人。

@linxianxi
Copy link
Contributor Author

另外这是一个好习惯,写给自己也写给社区其他人。

收到🫡

@zombieJ
Copy link
Member

zombieJ commented Aug 4, 2023

map filter 改成 reduce,少遍历一次。然后这里是递归,就不止少遍历一次了。

其实对于每层,还是少遍历一次。😈

@zombieJ zombieJ merged commit 03f3b24 into react-component:master Aug 4, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants