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 delegate allocations from FindAmbientValues #4733

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

stephentoub
Copy link
Member

Description

These were calling an ArrayHelper.ForAll, passing in a method group as a delegate, causing each call to allocate the delegate. The CheckAmbient helper being called was only used here, so rather than caching a delegate, I just inlined the code. The other ArrayHelper methods were each only used in one place, also, so I just inlined those, too, and deleted the helper class.

Customer Impact

Reduced impact on GC

Regression

No

Testing

Just CI

Risk

There is one potentially visible change here. If an invalid property was passed in to the public IAmbientProvider.Get*AmbientValues methods via the "properties" parameter, today it's throwing an ArgumentException using an internal name of "xamlProperty", and this change makes it so that the exception contains the actual parameter name "properties". I think the new naming is better, as it maps to names that actually make sense to the caller, but this can be backed out if preferred.

These were calling an ArrayHelper.ForAll, passing in a method group as a delegate, causing each call to allocate the delegate.  The CheckAmbient helper being called was only used here, so rather than caching a delegate, I just inlined the code.  The other ArrayHelper methods were each only used in one place, also, so I just inlined those, too, and deleted the helper class.

There is one potentially visible change here.  If an invalid property was passed in to the public IAmbientProvider.Get*AmbientValues methods via the "properties" parameter, today it's throwing an ArgumentException using an internal name of "xamlProperty", and this change makes it so that the exception contains the actual parameter name "properties".
@stephentoub stephentoub requested a review from a team as a code owner June 23, 2021 21:44
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jun 23, 2021
@ghost ghost requested review from fabiant3, ryalanms and SamBent June 23, 2021 21:44
@ryalanms ryalanms merged commit 2b59a6c into dotnet:main Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 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