-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Reduce time spent in ConflictResolver.Session.GetNodesOrTokensToCheckForConflicts #74101
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,15 +159,12 @@ public RenameRewriter(RenameRewriterParameters parameters) | |
|
||
var isInConflictLambdaBody = false; | ||
var lambdas = node.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax); | ||
if (lambdas.Count() != 0) | ||
foreach (var lambda in lambdas) | ||
{ | ||
foreach (var lambda in lambdas) | ||
if (_conflictLocations.Any(cf => cf.Contains(lambda.Span))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no 'any' that takes an arg? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't one available, and the only current extension methods we have on ImmutableHashSet are in the compiler, and I didn't want to change that in this PR. |
||
{ | ||
if (_conflictLocations.Any(cf => cf.Contains(lambda.Span))) | ||
{ | ||
isInConflictLambdaBody = true; | ||
break; | ||
} | ||
isInConflictLambdaBody = true; | ||
break; | ||
} | ||
} | ||
|
||
|
@@ -298,7 +295,7 @@ private SyntaxNode Complexify(SyntaxNode originalNode, SyntaxNode newNode) | |
RoslynDebug.Assert(_speculativeModel != null, "expanding a syntax node which cannot be speculated?"); | ||
|
||
var oldSpan = originalNode.Span; | ||
var expandParameter = originalNode.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax).Count() == 0; | ||
var expandParameter = !originalNode.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax).Any(); | ||
|
||
newNode = _simplificationService.Expand(newNode, | ||
_speculativeModel, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,9 +505,13 @@ private static bool IsConflictFreeChange( | |
private IEnumerable<(SyntaxNodeOrToken syntax, RenameActionAnnotation annotation)> GetNodesOrTokensToCheckForConflicts( | ||
SyntaxNode syntaxRoot) | ||
{ | ||
return syntaxRoot.DescendantNodesAndTokens(descendIntoTrivia: true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YIKES |
||
.Where(_renameAnnotations.HasAnnotations<RenameActionAnnotation>) | ||
.Select(s => (s, _renameAnnotations.GetAnnotations<RenameActionAnnotation>(s).Single())); | ||
foreach (var nodeOrToken in syntaxRoot.GetAnnotatedNodesAndTokens(RenameAnnotation.Kind)) | ||
{ | ||
var annotation = _renameAnnotations.GetAnnotations<RenameActionAnnotation>(nodeOrToken).FirstOrDefault(); | ||
|
||
if (annotation != null) | ||
yield return (nodeOrToken, annotation); | ||
} | ||
} | ||
|
||
private async Task<bool> CheckForConflictAsync( | ||
|
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.
YIKES