Browse Source

Reduce boxing allocations.

pull/3057/head
Dariusz Komosinski 7 years ago
parent
commit
ca1d231fce
  1. 2
      samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs
  2. 2
      src/Avalonia.Base/Utilities/SingleOrDictionary.cs
  3. 6
      src/Avalonia.Controls/Calendar/DatePicker.cs

2
samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs

@ -11,7 +11,7 @@ namespace ControlCatalog.ViewModels
public ItemsRepeaterPageViewModel() public ItemsRepeaterPageViewModel()
{ {
Items = new ObservableCollection<string>( Items = new ObservableCollection<string>(
Enumerable.Range(1, 100000).Select(i => $"Item {i}")); Enumerable.Range(1, 100000).Select(i => $"Item {i.ToString()}"));
} }
public ObservableCollection<string> Items { get; } public ObservableCollection<string> Items { get; }

2
src/Avalonia.Base/Utilities/SingleOrDictionary.cs

@ -38,7 +38,7 @@ namespace Avalonia.Utilities
{ {
if (dictionary == null) if (dictionary == null)
{ {
if (!_singleValue.HasValue || !_singleValue.Value.Key.Equals(key)) if (!_singleValue.HasValue || !EqualityComparer<TKey>.Default.Equals(_singleValue.Value.Key, key))
{ {
value = default(TValue); value = default(TValue);
return false; return false;

6
src/Avalonia.Controls/Calendar/DatePicker.cs

@ -1042,7 +1042,8 @@ namespace Avalonia.Controls
} }
} }
DateTime? d = SetTextBoxValue(s); DateTime? d = SetTextBoxValue(s);
if (!SelectedDate.Equals(d))
if (SelectedDate != d)
{ {
SelectedDate = d; SelectedDate = d;
} }
@ -1058,7 +1059,8 @@ namespace Avalonia.Controls
else else
{ {
DateTime? d = SetTextBoxValue(_defaultText); DateTime? d = SetTextBoxValue(_defaultText);
if (!SelectedDate.Equals(d))
if (SelectedDate != d)
{ {
SelectedDate = d; SelectedDate = d;
} }

Loading…
Cancel
Save