-
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 working with filters and extensions in FileDialog, decrease allocations #9599
Conversation
src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.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, feel free to resolve the conflicts. This can be merged post that.
f45e3e3
to
e4b63e2
Compare
@harshit7962 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.
Re-Approving
Thank you @h3xds1nz for the contribution. |
@harshit7962 Thank you :) |
Description
Decreases allocations and improves performance when working with
FileDialog
and the derived classes.COMDLG_FILTERSPEC
is now areadonly struct
, it is defined asconst
in the COM interop.StartsWith
,IndexOf
etc. with char overload instead of single-character strings.string.CompareOrdinal
replaced withstring.Equals(a, b, StringComparison.Ordinal)
string.Split
to getLength
we count them usingMemoryExtensions.Count
GetFilterItems
will no longer allocate aList<COMDLG_FILTERSPEC>
withToArray()
conversion.GetFilterExtensions
will no longer allocate aList<string>
withToArray()
conversion.FileDialog
and derived classes.Using
string.Split
vsMemoryExtensions.Count
for countingBenchmark code
GetFilterItems benchmark
Benchmark code
Customer Impact
Improved performance, decreased allocations.
Regression
No.
Testing
Local build, testing with file dialogs.
Risk
Low.
Microsoft Reviewers: Open in CodeFlow