Skip to content

Avoid unnecessary List<> wrapper in GetTextRunSpans#6516

Merged
dipeshmsft merged 1 commit intodotnet:mainfrom
stephentoub:textspanlist
Jun 3, 2022
Merged

Avoid unnecessary List<> wrapper in GetTextRunSpans#6516
dipeshmsft merged 1 commit intodotnet:mainfrom
stephentoub:textspanlist

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented May 2, 2022

Description

We know exactly how big the resulting list needs to be. As is done in other variants of this method, just allocate the array to be used as an IList. Also in one place where we do continue using a List<T>, strongly-type the local as such to avoid unnecessarily going through the interface.

Customer Impact

Unnecessary allocation

Regression

No

Testing

CI

Risk

Minimal. Other implementations already return arrays, so callers can't be expecting it'll always be a List<>.

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner May 2, 2022 15:23
@ghost ghost assigned stephentoub May 2, 2022
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label May 2, 2022
@ghost ghost requested review from SamBent, dipeshmsft and singhashish-wpf May 2, 2022 15:23
@dipeshmsft dipeshmsft merged commit e449235 into dotnet:main Jun 3, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants