-
Notifications
You must be signed in to change notification settings - Fork 728
perf: avoid double parsing and extra clones in doc signature formatting #9285
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: avoid double parsing and extra clones in doc signature formatting #9285
Conversation
orizi
left a comment
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.
@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @Fibonacci747).
crates/cairo-lang-doc/src/location_links.rs line 34 at r1 (raw file):
/// Collects all [`cairo_lang_syntax::node::green::GreenNode`]s for a [`SyntaxNode`], /// returns a vector of their [`SyntaxKind`] and text. fn collect_green_nodes<'db>(
and fix doc.
Suggestion:
fn extend_green_nodes<'db>(
fixed |
orizi
left a comment
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.
@orizi made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 1 files reviewed, all discussions resolved.
a discussion (no related file):
@FroyaTheHen
FroyaTheHen
left a comment
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.
@FroyaTheHen made 1 comment.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @orizi).
orizi
left a comment
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.
@orizi reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Fibonacci747).
Summary
This change removes redundant work when formatting documentation signatures. The virtual file is now parsed only once using a local DiagnosticsBuilder, while keeping the same “allow a single parse error” behavior. The helper get_virtual_syntax_file_signature now takes &str instead of String, so we no longer clone signature strings just to intern them for the virtual file. Additionally, collect_green_nodes was simplified to fill a provided vector in place instead of returning a cloned copy, and its call sites were updated accordingly.
Type of change
Please check one:
Why is this change needed?
These changes reduce unnecessary allocations and parsing overhead without affecting the observable behavior of location links.