From b31a7408d3c279e92480530fc6a8cd8167b435c2 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 13 Jun 2025 23:39:14 +0800 Subject: [PATCH] Simple refactor --- Flow.Launcher.Infrastructure/PinyinAlphabet.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs index 090abb490..2c548e0a3 100644 --- a/Flow.Launcher.Infrastructure/PinyinAlphabet.cs +++ b/Flow.Launcher.Infrastructure/PinyinAlphabet.cs @@ -30,18 +30,12 @@ namespace Flow.Launcher.Infrastructure public (string translation, TranslationMapping map) Translate(string content) { - if (_settings.ShouldUsePinyin) - { - if (true) - { - return BuildCacheFromContent(content); - } - //else - //{ - // return value; - //} - } - return (content, null); + if (!_settings.ShouldUsePinyin) + return (content, null); + + return _pinyinCache.TryGetValue(content, out var value) + ? value + : BuildCacheFromContent(content); } private (string translation, TranslationMapping map) BuildCacheFromContent(string content)