Skip to content

Move IDE off of SpecializedCollections.Singleton to using collectoin exprs#72899

Merged
CyrusNajmabadi merged 57 commits intodotnet:mainfrom
CyrusNajmabadi:singleton
Apr 6, 2024
Merged

Move IDE off of SpecializedCollections.Singleton to using collectoin exprs#72899
CyrusNajmabadi merged 57 commits intodotnet:mainfrom
CyrusNajmabadi:singleton

Conversation

@CyrusNajmabadi
Copy link
Contributor

Compiler has built in support for optimizing this case. If you have a singleton collection expr, you already get an optimal readonly compiler collection with space for just that single element.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 6, 2024 00:52
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 6, 2024
@ToddGrun
Copy link
Contributor

ToddGrun commented Apr 6, 2024

I assume a lot of those SpecializedClasses are now kept around only to minimize churn in the compiler? Should we ban a bunch of those classes from use outside that context so they don't sneak their way back in?

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
Copy link
Contributor Author

I assume a lot of those SpecializedClasses are now kept around only to minimize churn in the compiler? Should we ban a bunch of those classes from use outside that context so they don't sneak their way back in?

Works for me :)

@CyrusNajmabadi CyrusNajmabadi merged commit 14c0557 into dotnet:main Apr 6, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the singleton branch April 6, 2024 23:08
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 6, 2024
OnTagsChangedForBuffer(SpecializedCollections.SingletonCollection(
new KeyValuePair<ITextBuffer, DiffResult>(buffer, difference)),
OnTagsChangedForBuffer(
[new KeyValuePair<ITextBuffer, DiffResult>(buffer, difference)],
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one won't fit the pattern unless the signature for OnTagsChangedForBuffer changes


private static IList<SymbolDisplayPart> GetMethodGroupPostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseBracketToken));
}
=> [Punctuation(SyntaxKind.CloseBracketToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

// Since we're returning a single item, we can selected it as the "best one".
selectedItem = 0;

return SpecializedCollections.SingletonList(item);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

isOptional: false,
documentationFactory: null,
displayParts: parts));
return [new SignatureHelpSymbolParameter(
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

{
return SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
}
=> [Punctuation(SyntaxKind.CloseParenToken)];
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This one doesn't fit the pattern

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.

4 participants