Skip to content

Stop boxing in Visual.SetDpiScaleVisualFlags#6309

Merged
dipeshmsft merged 1 commit intodotnet:mainfrom
stephentoub:visualdpiboxing
May 5, 2022
Merged

Stop boxing in Visual.SetDpiScaleVisualFlags#6309
dipeshmsft merged 1 commit intodotnet:mainfrom
stephentoub:visualdpiboxing

Conversation

@stephentoub
Copy link
Member

Description

This uses DpiScale.Equals(DpiScale), but there's no such strongly-typed overload, so it falls back to using ValueType.Equals(object), which not only boxes the DpiScale but also both doubles that end up being compared. This just adds an internal Equals method to DpiScale to bind to that Equals instead; ideally in the future DpiScale would implement IEquatable<T> and this Equals would be made public.

Customer Impact

Unnecessary allocation / overhead

Regression

No

Testing

CI

Risk

Minimal

This uses DpiScale.Equals(DpiScale), but there's no such strongly-typed overload, so it falls back to using ValueType.Equals(object), which not only boxes the DpiScale but also both doubles that end up being compared.  This just adds an internal Equals method to DpiScale to bind to that Equals instead; ideally in the future DpiScale would implement `IEquatable<T>` and this `Equals` would be made public.
@stephentoub stephentoub requested a review from a team as a code owner March 25, 2022 03:21
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Mar 25, 2022
@ghost ghost requested review from SamBent, dipeshmsft and singhashish-wpf March 25, 2022 03:21
@dipeshmsft dipeshmsft self-assigned this Mar 28, 2022
@ghost ghost assigned stephentoub May 4, 2022
@dipeshmsft dipeshmsft merged commit 182e1da into dotnet:main May 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 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