From f4971e2e96ad0b59ced9dd79fd9718e0c1ec0b5b Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 18 Mar 2021 06:44:00 +1100 Subject: [PATCH] remove async and task run --- .../Search/WindowsIndex/IndexSearch.cs | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs index 559ef4647..174bdcfae 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs @@ -95,13 +95,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex return new List(); var constructedQuery = constructQuery(searchString); - return await RemoveResultsInExclusionList( + return RemoveResultsInExclusionList( await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token).ConfigureAwait(false), exclusionList, - token).ConfigureAwait(false); + token); } - private async static Task> RemoveResultsInExclusionList(List results, List exclusionList, CancellationToken token) + private static List RemoveResultsInExclusionList(List results, List exclusionList, CancellationToken token) { var indexExclusionListCount = exclusionList.Count; @@ -110,38 +110,28 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex var filteredResults = new List(); - try + for (var index = 0; index < results.Count; index++) { - await Task.Run(() => + token.ThrowIfCancellationRequested(); + + var excludeResult = false; + + for (var i = 0; i < indexExclusionListCount; i++) { - for (var index = 0; index < results.Count; index++) + token.ThrowIfCancellationRequested(); + + if (results[index].SubTitle.StartsWith(exclusionList[i].Path, StringComparison.OrdinalIgnoreCase)) { - token.ThrowIfCancellationRequested(); - - var excludeResult = false; - - for (var i = 0; i < indexExclusionListCount; i++) - { - token.ThrowIfCancellationRequested(); - - if (results[index].SubTitle.StartsWith(exclusionList[i].Path, StringComparison.OrdinalIgnoreCase)) - { - excludeResult = true; - break; - } - } - - if (!excludeResult) - filteredResults.Add(results[index]); + excludeResult = true; + break; } - }, token); + } - return filteredResults; - } - catch (OperationCanceledException) - { - return new List(); + if (!excludeResult) + filteredResults.Add(results[index]); } + + return filteredResults; } internal static bool PathIsIndexed(string path)