Skip to content

Remove an enumerator allocation in SymbolCompletionItem.CreateWorker#76375

Merged
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/RemoveEnumeratorAllocationInSymbolCompletionItem.CreateWorker
Dec 11, 2024
Merged

Remove an enumerator allocation in SymbolCompletionItem.CreateWorker#76375
ToddGrun merged 1 commit intodotnet:mainfrom
ToddGrun:dev/toddgrun/RemoveEnumeratorAllocationInSymbolCompletionItem.CreateWorker

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
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 11, 2024
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.


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.

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