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

Stop boxing WeakReferenceListEnumerator in PresentationSource use #6502

Merged

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Apr 29, 2022

Description

PresentationSource.CriticalCurrentSources is internal and is only ever foreach'd by consumers. It's strongly-typed to return IEnumerable, but the actual WeakReferenceList it returns has a struct-based enumerator, which means each foreach boxes that enumerator. By changing CriticalCurrentSources to return WeakReferenceList rather than IEnumerable, those foreach's can bind directly to the struct, with all the benefits that brings.

Customer Impact

Unnecessary allocation

Regression

No

Testing

CI

Risk

Minimal

Microsoft Reviewers: Open in CodeFlow

PresentationSource.CriticalCurrentSources is internal and is only ever foreach'd by consumers.  It's strongly-typed to return IEnumerable, but the actual WeakReferenceList it returns has a struct-based enumerator, which means each foreach boxes that enumerator.  By changing CriticalCurrentSources to return `WeakReferenceList` rather than `IEnumerable`, those foreach's can bind directly to the struct, with all the benefits that brings.
@stephentoub stephentoub requested a review from a team as a code owner April 29, 2022 13:53
@ghost ghost assigned stephentoub Apr 29, 2022
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Apr 29, 2022
@ghost ghost requested review from dipeshmsft, singhashish-wpf and SamBent April 29, 2022 13:53
@singhashish-wpf singhashish-wpf merged commit 81ddc95 into dotnet:main Jul 21, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 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
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants