-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Optimize FontSourceCollection creation from a filesystem directory, reduce allocs #9844
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
base: main
Are you sure you want to change the base?
Conversation
8ed3af8
to
2d57793
Compare
Resolved merge conflicts 11 |
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs
Show resolved
Hide resolved
2d57793
to
ada2d0e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9844 +/- ##
===================================================
+ Coverage 11.25778% 11.40499% +0.14720%
===================================================
Files 3315 3316 +1
Lines 665229 665209 -20
Branches 74668 74671 +3
===================================================
+ Hits 74890 75867 +977
+ Misses 589035 587938 -1097
- Partials 1304 1404 +100
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Rebased and moved things to ctor so that fields can be However, no code/logic changes have been done. |
Description
Optimizes building of
FontSourceCollection
and also some work inFontResourceCache
.Path.GetExtension
has a span variant, this prevents string creation just to checkIsSupportedFontExtension
.SupportedExtensions
static array has been removed as it is not needed for anything, anymore.isWindowsFonts
from the previous PR, hence why this is a draft.Directory.GetFiles
, we will use the underlying implementation on .NET Core; theFileSystemEnumerable
.Directory.GetFiles(string)
does (Compatible
).MatchType
to be specified at all (which would be Win32), so it is not.file://
, we will no longer allocate astring[]
of 1.416 files in directory, no matches
351 files in directory, 156 matches
5 files, 1 match
1 file, 1 match
Customer Impact
Decreased allocations, increased performance when initializing from directory.
I've observed about 3-4ms improvement when building from
Fonts
directory (351 files; 156 matches).Regression
No.
Testing
Local build, initializing the collection with folders to look in, testing the functinality via
FontFamily
change.Risk
Low, this is rather simple 1:1 swap. Options for
FileSystemEnumerable
were copied forGetFiles
codepath.Microsoft Reviewers: Open in CodeFlow