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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Specialized collectoin
  • Loading branch information
CyrusNajmabadi committed Apr 7, 2024
commit e9710f53fd5cc7b58d274d8797dedac2f3cc018e
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ public override IReadOnlyList<SyntaxNode> GetAttributeArguments(SyntaxNode attri
break;
}

return SpecializedCollections.EmptyReadOnlyList<SyntaxNode>();
return [];
}

public override SyntaxNode InsertAttributeArguments(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributeArguments)
Expand Down Expand Up @@ -1212,7 +1212,7 @@ public override IReadOnlyList<SyntaxNode> GetNamespaceImports(SyntaxNode declara
{
CompilationUnitSyntax compilationUnit => compilationUnit.Usings,
BaseNamespaceDeclarationSyntax namespaceDeclaration => namespaceDeclaration.Usings,
_ => SpecializedCollections.EmptyReadOnlyList<SyntaxNode>(),
_ => [],
};

public override SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports)
Expand Down Expand Up @@ -1241,7 +1241,7 @@ public override IReadOnlyList<SyntaxNode> GetMembers(SyntaxNode declaration)
EnumDeclarationSyntax @enum => @enum.Members,
BaseNamespaceDeclarationSyntax @namespace => @namespace.Members,
CompilationUnitSyntax compilationUnit => compilationUnit.Members,
_ => SpecializedCollections.EmptyReadOnlyList<SyntaxNode>(),
_ => [],
});

private static ImmutableArray<SyntaxNode> Flatten(IEnumerable<SyntaxNode> declarations)
Expand Down Expand Up @@ -2128,8 +2128,8 @@ public override IReadOnlyList<SyntaxNode> GetParameters(SyntaxNode declaration)
return list != null
? list.Parameters
: declaration is SimpleLambdaExpressionSyntax simpleLambda
? new[] { simpleLambda.Parameter }
: SpecializedCollections.EmptyReadOnlyList<SyntaxNode>();
? [simpleLambda.Parameter]
: [];
}

public override SyntaxNode InsertParameters(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> parameters)
Expand All @@ -2148,7 +2148,7 @@ public override SyntaxNode InsertParameters(SyntaxNode declaration, int index, I
public override IReadOnlyList<SyntaxNode> GetSwitchSections(SyntaxNode switchStatement)
{
var statement = switchStatement as SwitchStatementSyntax;
return statement?.Sections ?? SpecializedCollections.EmptyReadOnlyList<SyntaxNode>();
return statement?.Sections ?? [];
}

public override SyntaxNode InsertSwitchSections(SyntaxNode switchStatement, int index, IEnumerable<SyntaxNode> switchSections)
Expand Down Expand Up @@ -2456,7 +2456,7 @@ private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueCla
return declaration;
}

private static readonly IReadOnlyList<SyntaxNode> s_EmptyList = SpecializedCollections.EmptyReadOnlyList<SyntaxNode>();
private static readonly IReadOnlyList<SyntaxNode> s_EmptyList = [];
CyrusNajmabadi marked this conversation as resolved.
Show resolved Hide resolved

public override IReadOnlyList<SyntaxNode> GetStatements(SyntaxNode declaration)
{
Expand Down Expand Up @@ -2671,7 +2671,7 @@ public override IReadOnlyList<SyntaxNode> GetBaseAndInterfaceTypes(SyntaxNode de
}
else
{
return SpecializedCollections.EmptyReadOnlyList<SyntaxNode>();
return [];
}
}

Expand Down Expand Up @@ -2970,7 +2970,7 @@ private static IReadOnlyList<SyntaxNode> GetSubDeclarations(SyntaxNode declarati
SyntaxKind.LocalDeclarationStatement => ((LocalDeclarationStatementSyntax)declaration).Declaration.Variables,
SyntaxKind.VariableDeclaration => ((VariableDeclarationSyntax)declaration).Variables,
SyntaxKind.AttributeList => ((AttributeListSyntax)declaration).Attributes,
_ => SpecializedCollections.EmptyReadOnlyList<SyntaxNode>(),
_ => [],
};

public override SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node)
Expand Down