From e6218764534c18cf041b54055ddc539d1ef6c799 Mon Sep 17 00:00:00 2001 From: Zach Date: Mon, 2 Dec 2019 16:37:55 -0800 Subject: [PATCH] Replaced LINQ query with for loop. Upon reflection, the query looked nice, but was inferior to a plain for loop because it would have to create n anonymous objects to process the list, even with LINQ's filtering optimization, due to select preceding where. --- .../tools/Watch/WatchList/WatchList.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs index f259f95784..0c8b93793c 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs @@ -231,11 +231,14 @@ namespace BizHawk.Client.Common /// Defines the order of the sort. Ascending (true) or descending (false) public void OrderWatches(string column, bool reverse) { - var separatorIndices = _watchList.Select((w, i) => new { watch = w, index = i }) - .Where(w => w.watch.IsSeparator) - .Select(w => w.index) - .ToList(); - + var separatorIndices = new List(); + for (var i = 0; i < _watchList.Count; i++) + { + if (_watchList[i].IsSeparator) + { + separatorIndices.Add(i); + } + } separatorIndices.Add(_watchList.Count); // Sort "blocks" of addresses between separators.