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 an enumerator allocation in SymbolCompletionItem.CreateWorker #76375

Conversation

ToddGrun
Copy link
Contributor

This is a small allocation, only showing up as about 0.1% of allocationsi n the typing scenario in the csharp editing speedometer test. However, the change is fairly simple, and I prefer the change as it passes around ImmutableArrays instead of IReadOnlyLists.

*** relevant allocations from the csharp editing speedometer test ***
image

This is a small allocation, only showing up as about 0.1% of allocationsi n the typing scenario in the csharp editing speedometer test. However, the change is fairly simple, and I prefer the change as it passes around ImmutableArrays instead of IReadOnlyLists.
@ToddGrun ToddGrun requested a review from a team as a code owner December 11, 2024 16:02
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 11, 2024
@@ -82,28 +82,6 @@ public static bool IsStartingNewWord(SourceText text, int characterPosition, Fun
return true;
}

public static Func<CancellationToken, Task<CompletionDescription>> CreateDescriptionFactory(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

public static Func<CancellationToken, Task> CreateDescriptionFactory(

These don't appear to be used anymore.


builder.Add(KeyValuePairUtil.Create("ContextPosition", contextPosition.ToString()));
AddSupportedPlatforms(builder, supportedPlatforms);
symbolEncoder(symbols, builder);

tags = tags.NullToEmpty();
if (symbols.All(symbol => symbol.IsObsolete()) && !tags.Contains(WellKnownTags.Deprecated))
if (!tags.Contains(WellKnownTags.Deprecated) && symbols.All(static symbol => symbol.IsObsolete()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

!tags.Contains(WellKnownTags.Deprecated)

order switched here as the IsObsolete checks allocate quite a bit. I doubt the caller has this tag set already in tags, but this seemed nicer.

@@ -42,7 +43,7 @@ public static CompletionItem CreateSymbolCompletionItem(
SupportedPlatformData? supportedPlatforms = null,
ImmutableDictionary<string, string>? properties = null,
ImmutableArray<string> tags = default)
=> SymbolCompletionItem.CreateWithSymbolId(displayText, displayTextSuffix: null, symbols, rules, contextPosition, sortText, insertionText,
=> SymbolCompletionItem.CreateWithSymbolId(displayText, displayTextSuffix: null, symbols.ToImmutableArray(), rules, contextPosition, sortText, insertionText,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ToImmutableArray

This is potentially an allocation where it wasn't before, but only if they weren't using an ImmutableArray and it's limited to Pythia.

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 VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants