-
Notifications
You must be signed in to change notification settings - Fork 441
Move AbsoluteSyntaxInfo to "edge" SyntaxData information #659
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
Conversation
@swift-ci Please test |
3255377
to
96d70de
Compare
@swift-ci Please test |
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.
I’m not really comfortable with the name edge
. Otherwise LGTM.
Sources/SwiftSyntax/SyntaxData.swift
Outdated
init(_ value: Syntax) { | ||
self.value = value | ||
// For non-root nodes. | ||
struct Edge { |
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.
I don’t like the term edge
here. To me the edge would be information that’s related to the parent-child relationship between two nodes. But absoluteInfo
is information about this node in the entire tree.
It’s not a great name but NonRoot
would make me stumble a lot less.
rdar://99492992 |
The root node doesn't need to hold its `AbsoluteSyntaxInfo` because it's always zero. Move this information to "edge" data so only non-root nodes hold the "absolute info". Introduce an "edge" info struct, and use it with `indirect` enum case instead of `SyntaxBox`. Previously the structure of `SyntaxData` was: * AbsoluteRawSyntax * RawSyntax * AbsoluteSyntaxInfo * Tagged union of * SyntaxArena * SyntaxBox * Parent SyntaxData Now: * RawSyntax node * Tagged union of: * SyntaxData.Info.Root * SyntaxArena * SyntaxData.Info.Edge (indirect case) * Parent SyntaxData * AbsoluteSyntaxInfo This reduces the size of `SyntaxData` to 2 words. Also `SyntaxData.parent` now returns `SyntaxData` instead of `Syntax`. `SyntaxData` should not rely on `Syntax` API at all.
96d70de
to
53d91e8
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
The root node doesn't need to hold its
AbsoluteSyntaxInfo
because it's always zero. Move this information to "edge" data so only non-root nodes hold the "absolute info". Introduce an "edge" info struct, and use it withindirect
enum case instead ofSyntaxBox
.Previously the structure of
SyntaxData
was:Now:
This reduces the size of
SyntaxData
to 2 words.Also
SyntaxData.parent
now returnsSyntaxData
instead ofSyntax
.SyntaxData
should not rely onSyntax
API at all.As for the performance, compared to pre #635, this improves
testEmptyAnyVistorPerformance
/testEmptyRewriterPerformance
/testEmptyVisitorPerformance
by 5-10%.