-
Couldn't load subscription status.
- Fork 638
Keeping SyntaxNode parent's data id for optimizations #8513
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
Keeping SyntaxNode parent's data id for optimizations #8513
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
6b047cc to
49347d0
Compare
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.
@TomerStarkware reviewed 4 of 4 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @orizi)
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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @eytan-starkware)
crates/cairo-lang-syntax/src/node/mod.rs line 188 at r1 (raw file):
ptr = ptr.and_then(|p| p.parent(db)); } ptr.unwrap_or_else(|| {
Suggestion:
let mut result = Some(*self);
while let Some(p) = result && n > 1 {
result = p.grandparent(db);
n -= 2;
}
if let Some(p) = result && n == 1 {
result = p.parent(db);
}
result.unwrap_or_else(|| {148a496 to
b8f0747
Compare
49347d0 to
010cd59
Compare
010cd59 to
c071884
Compare
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.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @orizi and @TomerStarkware)
crates/cairo-lang-syntax/src/node/mod.rs line 188 at r1 (raw file):
ptr = ptr.and_then(|p| p.parent(db)); } ptr.unwrap_or_else(|| {
Done.
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 2 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @eytan-starkware)
b8f0747 to
9dc334b
Compare
c071884 to
8dfde2b
Compare
8dfde2b to
a6b60a0
Compare
9dc334b to
487304f
Compare
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 of 1 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @eytan-starkware)
a6b60a0 to
d60d5d2
Compare
Merge activity
|

TL;DR
Optimize SyntaxNode parent lookups by caching parent data to reduce database queries.
What changed?
SyntaxNodeto cache parent data, avoiding repeated database lookupsis_root()andgrandparent()to improve code readabilitynth_parent()to use cached parent data when possiblefile_id(),parent_kind().parent(db)calls with more efficient alternatives throughout the codebase