Skip to content
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

Remove more usages of specialized collections in favor of collection exprs #72918

Merged
merged 23 commits into from
Apr 7, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 7, 2024
@CyrusNajmabadi CyrusNajmabadi changed the title Specialized collections Remove more usages of specialized collections in favor of collection exprs Apr 7, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review April 7, 2024 19:23
@CyrusNajmabadi CyrusNajmabadi requested review from a team as code owners April 7, 2024 19:23
Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 08d23b6 into dotnet:main Apr 7, 2024
28 of 30 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 7, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the moreSpecialized branch April 7, 2024 22:52
@@ -31,7 +31,7 @@ internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNo

internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, SyntaxNode executableCodeBlock, CancellationToken cancellationToken)
{
return GetDeclarationInfo(model, node, getSymbol, SpecializedCollections.SingletonEnumerable(executableCodeBlock), cancellationToken);
return GetDeclarationInfo(model, node, getSymbol, [executableCodeBlock], cancellationToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally do not welcome changes like this under Compilers.

@CyrusNajmabadi
Copy link
Member Author

Odd. This wasn't meant to touch the compiler. Will revert.

@@ -71,7 +71,7 @@ public static ICollection<ISymbol> GetMissingEnumMembers(ISwitchOperation switch
if (!TryGetAllEnumMembers(switchExpressionType, enumMembers) ||
!TryRemoveExistingEnumMembers(switchStatement, enumMembers))
{
return SpecializedCollections.EmptyCollection<ISymbol>();
return [];
Copy link
Member

@sharwell sharwell Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ What type gets constructed for this case? I would expect this change introduced a new allocation due to the return type.

{
return SpecializedCollections.EmptyList<TextChange>();
}
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -35,7 +35,7 @@ public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
return classifications.Where(c => c.Span.IntersectsWith(span)).ToList();
}

return SpecializedCollections.EmptyList<ClassificationSpan>();
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -55,7 +55,7 @@ public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
}
}

return SpecializedCollections.EmptyList<ClassificationSpan>();
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -97,7 +97,7 @@ private static IList<ITextView> GetTextViews(ITextBuffer textBuffer)
{
if (!s_map.TryGetValue(textBuffer, out var set))
{
return SpecializedCollections.EmptyList<ITextView>();
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -632,7 +632,7 @@ private void LogRenameSession(RenameLogMessage.UserActionOutcome outcome, bool p
outcome,
conflictResolutionFinishedComputing,
previewChanges,
SpecializedCollections.EmptyList<InlineRenameReplacementKind>()));
replacementKinds: []));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -269,7 +269,7 @@ private static IList<string> CollectLogHubFilePaths()
// ignore failures
}

return SpecializedCollections.EmptyList<string>();
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -84,7 +84,7 @@ public IList<TextChange> FormatToken(SyntaxToken token, CancellationToken cancel
if (previousToken.Kind() == SyntaxKind.None)
{
// no previous token. nothing to format
return SpecializedCollections.EmptyList<TextChange>();
return [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -52,7 +50,7 @@ public IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSp

if (spansToFormat.Count == 0)
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
return CreateAggregatedFormattingResult(node, results: []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

@@ -72,7 +70,7 @@ public IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSp
// quick simple case check
if (results == null)
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
return CreateAggregatedFormattingResult(node, results: []);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

return info == null
? SpecializedCollections.EmptyList<ISymbol>()
: info._imports;
return info == null ? [] : info._imports;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This appears to be a new allocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants