-
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
Remove allocations on all base converters, improve TokenizerHelper #9364
base: main
Are you sure you want to change the base?
Conversation
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/LengthConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/LengthConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/LengthConverter.cs
Outdated
Show resolved
Hide resolved
4a84838
to
15380c3
Compare
15380c3
to
beced18
Compare
4cb1aca
to
aadcc3b
Compare
Resolved merge conflicts 12, there are better ways to spent an hour and a half. |
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.
Side note: @h3xds1nz when there's a review on a PR I recommend adding new commits and doing merges instead of rebasing. It makes it much easier to track what changed since the last review.
...crosoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs
Show resolved
Hide resolved
|
||
PixelUnit pixelUnit; | ||
if (PixelUnit.TryParsePixel(valueSpan, out pixelUnit) | ||
|| PixelUnit.TryParsePixelPerInch(valueSpan, out pixelUnit) |
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.
Is the ||
or &&
at the start of the line instead of at the end of the line wrong according to the coding style ? Both seems to be used a lot and if one isn't better than the other I don't see a reason to change it.
if (valueSpan.Equals("auto", StringComparison.OrdinalIgnoreCase)) | ||
return Double.NaN; | ||
|
||
PixelUnit pixelUnit; |
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.
When I wrote this I put it on its own line on purpose because I think it's cleaner when the variable is used multiple times. Is there a reason you changed it ? I know there's an IDE0018 suggestion to change it but projects like winforms or runtime keep it as a suggestion and reason might be that sometimes it's cleaner not to do 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.
I will revert the stylistic changes to your code before merge if you think it's cleaner, as it is your code. I just auto formatted here (which does for me a tad more than pure .editorconfig).
...crosoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs
Show resolved
Hide resolved
Hey @h3xds1nz, |
aadcc3b
to
270db60
Compare
@himgoyalmicro Right, that was silly. Fixed.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9364 +/- ##
===================================================
+ Coverage 11.17950% 11.41570% +0.23619%
===================================================
Files 3314 3316 +2
Lines 665182 665312 +130
Branches 74668 74690 +22
===================================================
+ Hits 74364 75950 +1586
+ Misses 589525 587950 -1575
- Partials 1293 1412 +119
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
d0a827e
to
3c551cb
Compare
Description
This is probably one of the impactful PRs I've posted; optimizes conversion/parsing of all the base-generated types but also
ThicknessConverter
(once more),CornerRadiusConverter
,KeySplineConverter
andVirtualizationCacheLengthConverter
.Completely removes any allocations caused by the original Tokenizer by using
ReadOnlySpan<char>
instead of substrings.I have also introduced a
ref struct
variant that can be used in any code that doesn't compile fornet472
.MilCodeGen has also been adjusted to support this.
Single Thickness parsing (4 units)
Parsing Thickness 10 times (4 units)
Creation of 10x Matrix3D via Parse
Customer Impact
Improved performance by around 20% on base types, zeroed out allocations.
Regression
No.
Testing
Local build, basic testing of the tokenizer with span and some of the converters.
Risk
Low, the scope of the PR is big but with a simple change, hence any mistakes shall be easy to figure out on a DRT run.
Microsoft Reviewers: Open in CodeFlow