-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Optimize conversion of Key enum from/to string, reduce allocations #9697
Conversation
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Input/KeyConverter.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@h3xds1nz, could you please address the minor nits and the merge conflict? Let me know if you’d like me to resolve the conflicts.
20846b3
to
ae7bac8
Compare
@harshit7962 Thanks, merge conflicts fixed. I've additionally fixed the word "representation" on two occurrences as I've misspelled it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reapproving post resolution of conflicts and review comments.
Thank you @h3xds1nz for the contribution and prompt resolution of conflicts. |
@harshit7962 Thank you for reviewing; if we could queue up #9683 (already went through test pass) for review I could get started on MouseGesture/KeyGesture converters finally. |
Sure, will prioritize #9683 along with other PRs that you have mentioned already. |
Description
Parsing optimization for
Key
and its conversion from/to string. Conversion from is now alloc-free, conversion to is either untouched or free.ConvertFrom
is now allocation free, optimizing performance from x4 for normal keys to x20 for F1-F12 keys.ConvertTo
is pretty much unchanged however F10-F12 were added to switch as those are interned.ConvertFrom benchmarks (code size is not real here 'cause depth is set to 1)
ConvertTo benchmarks
Customer Impact
Increased performance, zero/reduced allocations.
Regression
No.
Testing
Local build, CI, assert tests:
Risk
Low, changes have been thoroughly tested.
Microsoft Reviewers: Open in CodeFlow