-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Avoid unnecessary full tree walks in the simplifier system #73473
Conversation
src/Workspaces/Core/Portable/Simplification/AbstractSimplificationService.cs
Outdated
Show resolved
Hide resolved
@@ -166,6 +165,9 @@ bool isNodeOrTokenOutsideSimplifySpans(SyntaxNodeOrToken nodeOrToken) | |||
} | |||
|
|||
return document; | |||
|
|||
bool IsNodeOrTokenOutsideSimplifySpans(SyntaxNodeOrToken nodeOrToken) |
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.
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.
can do later (it's already being touched in #73471)
var hasImportsToSimplify = root != originalRoot; | ||
|
||
if (hasImportsToSimplify) | ||
{ | ||
document = document.WithSyntaxRoot(root); | ||
semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false); | ||
root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); | ||
root = (TCompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); |
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.
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.
yes. when we set the root, we get a new syntax tree with the root parented by that (that involves a fork of the red node, but it reuses the underlying green node).
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.
Drops us from:
to:
Note: there are much more wins from this as this basically drops practically every syntax node kind. All up this lowers us 25% from:
to: