Skip to content

Commit 2c53648

Browse files
committed
refactor: adjust IgnoreAccents handling logic in StringMatcher
Refined the logic to ensure Normalize is only invoked when IgnoreAccents is enabled, avoiding unnecessary calls and potential performance impact.
1 parent 54a458d commit 2c53648

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

Flow.Launcher.Infrastructure/StringMatcher.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,21 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
8686
int acronymsTotalCount = 0;
8787
int acronymsMatched = 0;
8888

89-
var fullStringToCompareAndNormalize = opt.IgnoreCase ? Normalize(stringToCompare) : stringToCompare;
90-
var queryWithoutCaseAndNormalize = opt.IgnoreCase ? Normalize(query) : query;
89+
var fullStringToCompare = stringToCompare;
90+
var queryToCompare = query;
9191

92-
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
93-
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
92+
if (_settings.IgnoreAccents)
93+
{
94+
fullStringToCompare = Normalize(fullStringToCompare);
95+
queryToCompare = Normalize(queryToCompare);
96+
}
97+
98+
if (opt.IgnoreCase)
99+
{
100+
fullStringToCompare = fullStringToCompare.ToLower();
101+
queryToCompare = queryToCompare.ToLower();
102+
}
94103

95-
var fullStringToCompare = _settings.IgnoreAccents ? fullStringToCompareAndNormalize : fullStringToCompareWithoutCase;
96-
var queryToCompare = _settings.IgnoreAccents ? queryWithoutCaseAndNormalize : queryWithoutCase;
97104

98105
var querySubstrings = queryToCompare.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
99106
int currentQuerySubstringIndex = 0;

0 commit comments

Comments
 (0)