Skip to content

Commit 74f1b05

Browse files
committed
make map variable more clear + formatting
1 parent 81733d3 commit 74f1b05

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Flow.Launcher.Infrastructure/PinyinAlphabet.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public int MapToOriginalIndex(int translatedIndex)
4545

4646
int count = 0;
4747

48-
4948
// Corner case handle
5049
if (translatedIndex < translatedIndexs[0])
5150
return translatedIndex;
@@ -113,7 +112,6 @@ public class PinyinAlphabet : IAlphabet
113112
private ConcurrentDictionary<string, (string translation, TranslationMapping map)> _pinyinCache =
114113
new ConcurrentDictionary<string, (string translation, TranslationMapping map)>();
115114

116-
117115
private Settings _settings;
118116

119117
public void Initialize([NotNull] Settings settings)

Flow.Launcher.Infrastructure/StringMatcher.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
4747
return new MatchResult(false, UserSettingSearchPrecision);
4848

4949
query = query.Trim();
50-
TranslationMapping map;
51-
(stringToCompare, map) = _alphabet?.Translate(stringToCompare) ?? (stringToCompare, null);
50+
TranslationMapping translationMapping;
51+
(stringToCompare, translationMapping) = _alphabet?.Translate(stringToCompare) ?? (stringToCompare, null);
5252

5353
var currentAcronymQueryIndex = 0;
5454
var acronymMatchData = new List<int>();
55-
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
5655

5756
// preset acronymScore
5857
int acronymScore = 100;
5958

6059
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
60+
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
6161

6262
var querySubstrings = queryWithoutCase.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
6363
int currentQuerySubstringIndex = 0;
@@ -136,7 +136,6 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
136136
continue;
137137
}
138138

139-
140139
if (firstMatchIndex < 0)
141140
{
142141
// first matched char will become the start of the compared string
@@ -197,7 +196,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
197196
// return acronym Match if possible
198197
if (acronymMatchData.Count == query.Length && acronymScore >= (int) UserSettingSearchPrecision)
199198
{
200-
acronymMatchData = acronymMatchData.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
199+
acronymMatchData = acronymMatchData.Select(x => translationMapping?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
201200
return new MatchResult(true, UserSettingSearchPrecision, acronymMatchData, acronymScore);
202201
}
203202

@@ -208,7 +207,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
208207
var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex - nearestSpaceIndex - 1,
209208
lastMatchIndex - firstMatchIndex, allSubstringsContainedInCompareString);
210209

211-
var resultList = indexList.Select(x => map?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
210+
var resultList = indexList.Select(x => translationMapping?.MapToOriginalIndex(x) ?? x).Distinct().ToList();
212211
return new MatchResult(true, UserSettingSearchPrecision, resultList, score);
213212
}
214213

0 commit comments

Comments
 (0)