From 590ebee47e9115ddd9e7cb777a4eea1351519b88 Mon Sep 17 00:00:00 2001 From: MikeFH Date: Sun, 14 Mar 2021 11:04:31 +0100 Subject: [PATCH] Move comparer selection to start of search --- ILSpy/Search/SearchPane.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ILSpy/Search/SearchPane.cs b/ILSpy/Search/SearchPane.cs index 204457c08..54fc2cad9 100644 --- a/ILSpy/Search/SearchPane.cs +++ b/ILSpy/Search/SearchPane.cs @@ -49,6 +49,7 @@ namespace ICSharpCode.ILSpy const int MAX_REFRESH_TIME_MS = 10; // More means quicker forward of data, less means better responsibility RunningSearch currentSearch; bool runSearchOnNextShow; + IComparer resultsComparer; public static readonly DependencyProperty ResultsProperty = DependencyProperty.Register("Results", typeof(ObservableCollection), typeof(SearchPane), @@ -211,7 +212,7 @@ namespace ICSharpCode.ILSpy int resultsAdded = 0; while (Results.Count < MAX_RESULTS && timer.ElapsedMilliseconds < MAX_REFRESH_TIME_MS && currentSearch.resultQueue.TryTake(out var result)) { - InsertResult(Results, result); + Results.InsertSorted(result, resultsComparer); ++resultsAdded; } @@ -230,6 +231,9 @@ namespace ICSharpCode.ILSpy currentSearch = null; } + resultsComparer = DisplaySettingsPanel.CurrentDisplaySettings.SortResults ? + SearchResult.ComparerByFitness : + SearchResult.ComparerByName; Results.Clear(); RunningSearch startedSearch = null; @@ -252,15 +256,6 @@ namespace ICSharpCode.ILSpy } } - void InsertResult(IList results, SearchResult result) - { - var comparer = DisplaySettingsPanel.CurrentDisplaySettings.SortResults ? - SearchResult.ComparerByFitness : - SearchResult.ComparerByName; - - results.InsertSorted(result, comparer); - } - void JumpToSelectedItem() { if (listBox.SelectedItem is SearchResult result)