Browse Source
Adjusted AvaloniaPropertyDictionary growth rate to reduce allocations
pull/10478/head
Julien Lebosquain
4 years ago
No known key found for this signature in database
GPG Key ID: 1833CAD10ACC46FD
1 changed files with
3 additions and
7 deletions
-
src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs
|
|
|
@ -304,13 +304,9 @@ namespace Avalonia.Utilities |
|
|
|
{ |
|
|
|
if (_entryCount == _entries!.Length) |
|
|
|
{ |
|
|
|
const double growthFactor = 1.2; |
|
|
|
var newSize = (int)(_entryCount * growthFactor); |
|
|
|
|
|
|
|
if (newSize == _entryCount) |
|
|
|
{ |
|
|
|
newSize++; |
|
|
|
} |
|
|
|
var newSize = _entryCount == DefaultInitialCapacity ? |
|
|
|
DefaultInitialCapacity * 2 : |
|
|
|
(int)(_entryCount * 1.5); |
|
|
|
|
|
|
|
var destEntries = new Entry[newSize]; |
|
|
|
|
|
|
|
|