From 1cbed83405318aeab89b99d833154a8dcf25eaa1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 22 Feb 2020 10:54:01 +0100 Subject: [PATCH] Tweak SelectionModelChangeSet. - Make field readonly - Use lambda syntax so C# caches delegates --- src/Avalonia.Controls/SelectionModelChangeSet.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Controls/SelectionModelChangeSet.cs b/src/Avalonia.Controls/SelectionModelChangeSet.cs index bff84eca92..6e77dc5755 100644 --- a/src/Avalonia.Controls/SelectionModelChangeSet.cs +++ b/src/Avalonia.Controls/SelectionModelChangeSet.cs @@ -7,7 +7,7 @@ namespace Avalonia.Controls { internal class SelectionModelChangeSet { - private List _changes; + private readonly List _changes; public SelectionModelChangeSet(List changes) { @@ -63,7 +63,7 @@ namespace Avalonia.Controls { static int GetCount(SelectionNodeOperation info) => info.DeselectedCount; static List? GetRanges(SelectionNodeOperation info) => info.DeselectedRanges; - return GetIndexAt(infos, index, GetCount, GetRanges); + return GetIndexAt(infos, index, x => GetCount(x), x => GetRanges(x)); } private IndexPath GetSelectedIndexAt( @@ -72,7 +72,7 @@ namespace Avalonia.Controls { static int GetCount(SelectionNodeOperation info) => info.SelectedCount; static List? GetRanges(SelectionNodeOperation info) => info.SelectedRanges; - return GetIndexAt(infos, index, GetCount, GetRanges); + return GetIndexAt(infos, index, x => GetCount(x), x => GetRanges(x)); } private object? GetDeselectedItemAt( @@ -81,7 +81,7 @@ namespace Avalonia.Controls { static int GetCount(SelectionNodeOperation info) => info.Items != null ? info.DeselectedCount : 0; static List? GetRanges(SelectionNodeOperation info) => info.DeselectedRanges; - return GetItemAt(infos, index, GetCount, GetRanges); + return GetItemAt(infos, index, x => GetCount(x), x => GetRanges(x)); } private object? GetSelectedItemAt( @@ -90,7 +90,7 @@ namespace Avalonia.Controls { static int GetCount(SelectionNodeOperation info) => info.Items != null ? info.SelectedCount : 0; static List? GetRanges(SelectionNodeOperation info) => info.SelectedRanges; - return GetItemAt(infos, index, GetCount, GetRanges); + return GetItemAt(infos, index, x => GetCount(x), x => GetRanges(x)); } private IndexPath GetIndexAt(