Browse Source

Merge pull request #3057 from MarchingCube/alloc-boxing

Misc boxing allocation removal.
Jumar Macato 6 years ago
parent
commit
45f36dbd41

+ 1 - 1
samples/ControlCatalog/Pages/ListBoxPage.xaml.cs

@@ -78,7 +78,7 @@ namespace ControlCatalog.Pages
                 }
             }
 
-            private string GenerateItem() => $"Item {_counter++}";
+            private string GenerateItem() => $"Item {_counter++.ToString()}";
         }
     }
 }

+ 1 - 1
samples/ControlCatalog/ViewModels/ItemsRepeaterPageViewModel.cs

@@ -11,7 +11,7 @@ namespace ControlCatalog.ViewModels
         public ItemsRepeaterPageViewModel()
         {
             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; }

+ 1 - 1
src/Avalonia.Base/Utilities/SingleOrDictionary.cs

@@ -38,7 +38,7 @@ namespace Avalonia.Utilities
         {
             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);
                     return false;

+ 4 - 2
src/Avalonia.Controls/Calendar/DatePicker.cs

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