-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(formatter): Skip bodies without comments #4978
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
febb93c
to
4b11d3c
Compare
4b11d3c
to
581634a
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
The benchmarks compare against |
With #4964 (comment), i don't really see much performance difference |
7458b5b
to
e341c1c
Compare
Improve the performance of the comments extraction by skipping bodies that contain no comments.
581634a
to
2b36a62
Compare
The linux result are in the range of what I expected and was able to reproduce locally. Not sure what happened with the windows run. |
Summary
This PR improves the performance of the comments extraction by skipping over bodies that contain no comments.
The visitor already avoided visiting the children of a node if there are no comments in its range but we aren't doing this yet for bodies because bodies are not nodes.
This PR adds the logic for skipping over bodies if there's no comment in the body range.
The old implementation did visit the
if
statement, as well as thebody
andorelse
because it contains a comment in its range. But this is unnecessarybecause only the case header has a comment.
Test Plan
cargo test