-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Set capacity of XAML resource dictionaries #15069
Conversation
You can test this PR using the following package version. |
7929709
to
c82f8a5
Compare
You can test this PR using the following package version. |
/// Ensures that the resource dictionary can hold up to <paramref name="capacity"/> entries without | ||
/// any further expansion of its backing storage. | ||
/// </summary> | ||
/// <remarks>This method may have no effect when targeting .NET Standard 2.0.</remarks> |
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.
This remark is partially outdated now.
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've changed it to "may have" since it's still true that it doesn't do anything when on .NET standard and the inner dictionary is already initialized.
What does the pull request do?
This PR adds a new
EnsureCapacity
toResourceDictionary
, used to prepare its backing storage for new items.The XAML compiler now calls this method before adding items to the
ResourceDictionary
, since it knows how many will be added.This avoids expanding the capacity several times at startup (for example,
FluentTheme
has dictionaries with up to 709 items), saving memory allocations.