Skip to content

Commit 1e016d7

Browse files
committed
optimize use
1 parent 59e61ce commit 1e016d7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Flow.Launcher.Infrastructure/StringMatcher.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
7171
|| (char.IsWhiteSpace(c) && char.ToLower(stringToCompare[++compareIndex]) ==
7272
queryWithoutCase[currentQueryIndex])
7373
|| (char.IsNumber(c) && c == queryWithoutCase[currentQueryIndex]):
74-
acronymMatchData.Add(map?.MapToOriginalIndex(compareIndex) ?? compareIndex);
74+
acronymMatchData.Add(compareIndex);
7575
currentQueryIndex++;
7676
continue;
7777

@@ -86,7 +86,10 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
8686
}
8787

8888
if (acronymMatchData.Count == query.Length && acronymScore >= 60)
89+
{
90+
acronymMatchData = acronymMatchData.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
8991
return new MatchResult(true, UserSettingSearchPrecision, acronymMatchData, acronymScore);
92+
}
9093

9194
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
9295

@@ -188,7 +191,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
188191
var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex - nearestSpaceIndex - 1,
189192
lastMatchIndex - firstMatchIndex, allSubstringsContainedInCompareString);
190193

191-
var resultList = indexList.Distinct().Select(x => map?.MapToOriginalIndex(x) ?? x).ToList();
194+
var resultList = indexList.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
192195
return new MatchResult(true, UserSettingSearchPrecision, resultList, score);
193196
}
194197

0 commit comments

Comments
 (0)