From 1003ce416093d2320892c75f50b2082a522cc2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Thu, 7 Jan 2021 21:48:55 +0800 Subject: [PATCH] move using to more specific place in Google.cs --- .../SuggestionSources/Google.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs index 17153b9a7..5c784a702 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs @@ -32,24 +32,24 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources return new List(); } - using (resultStream) + + if (resultStream.Length == 0) return new List(); + JsonDocument json; + try { - if (resultStream.Length == 0) return new List(); - JsonDocument json; - try - { + using (resultStream) json = await JsonDocument.ParseAsync(resultStream); - } - catch (JsonException e) - { - Log.Exception("|Google.Suggestions|can't parse suggestions", e); - return new List(); - } - - var results = json?.RootElement.EnumerateArray().ElementAt(1); - - return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List(); } + catch (JsonException e) + { + Log.Exception("|Google.Suggestions|can't parse suggestions", e); + return new List(); + } + + var results = json?.RootElement.EnumerateArray().ElementAt(1); + + return results?.EnumerateArray().Select(o => o.GetString()).ToList() ?? new List(); + } public override string ToString()