Skip to content

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

Merged
CyrusNajmabadi merged 23 commits intodotnet:mainfrom
CyrusNajmabadi:moreSpecialized
Apr 7, 2024
Merged

Remove more usages of specialized collections in favor of collection exprs#72918
CyrusNajmabadi merged 23 commits intodotnet:mainfrom
CyrusNajmabadi:moreSpecialized

Conversation

@CyrusNajmabadi
Copy link
Contributor

No description provided.

@ghost ghost 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 enabled auto-merge April 7, 2024 21:32
@CyrusNajmabadi CyrusNajmabadi merged commit 08d23b6 into dotnet:main Apr 7, 2024
@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
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
Contributor Author

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

!TryRemoveExistingEnumMembers(switchStatement, enumMembers))
{
return SpecializedCollections.EmptyCollection<ISymbol>();
return [];
Copy link
Contributor

@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
Contributor

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 SpecializedCollections.EmptyList<ClassificationSpan>();
return [];
Copy link
Contributor

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 SpecializedCollections.EmptyList<ClassificationSpan>();
return [];
Copy link
Contributor

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

if (!s_map.TryGetValue(textBuffer, out var set))
{
return SpecializedCollections.EmptyList<ITextView>();
return [];
Copy link
Contributor

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

conflictResolutionFinishedComputing,
previewChanges,
SpecializedCollections.EmptyList<InlineRenameReplacementKind>()));
replacementKinds: []));
Copy link
Contributor

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 SpecializedCollections.EmptyList<string>();
return [];
Copy link
Contributor

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

{
// no previous token. nothing to format
return SpecializedCollections.EmptyList<TextChange>();
return [];
Copy link
Contributor

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

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

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

if (results == null)
{
return CreateAggregatedFormattingResult(node, SpecializedCollections.EmptyList<AbstractFormattingResult>());
return CreateAggregatedFormattingResult(node, results: []);
Copy link
Contributor

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
Contributor

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