From 78a20865350e6994105e1185b496e211d289a49f Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Tue, 7 Jan 2020 08:04:56 +1100 Subject: [PATCH] Remove containedFully variable state Not necessary to have and not needed to add another dimension to the scoring --- Wox.Infrastructure/StringMatcher.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index a5162c281..27f99b2a6 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -138,9 +138,7 @@ namespace Wox.Infrastructure // proceed to calculate score if every char or substring without whitespaces matched if (allQuerySubstringsMatched) { - // check if all query substrings were contained in the string to compare - bool containedFully = lastMatchIndex - firstMatchIndex == queryWithoutCase.Length; - var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex, lastMatchIndex - firstMatchIndex, containedFully, allSubstringsContainedInCompareString); + var score = CalculateSearchScore(query, stringToCompare, firstMatchIndex, lastMatchIndex - firstMatchIndex, allSubstringsContainedInCompareString); var pinyinScore = ScoreForPinyin(stringToCompare, query); var result = new MatchResult @@ -194,8 +192,7 @@ namespace Wox.Infrastructure return currentQuerySubstringIndex >= querySubstringsLength; } - private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen, - bool isFullyContained, bool allWordsFullyMatched) + private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen, bool allWordsFullyMatched) { // A match found near the beginning of a string is scored more than a match found near the end // A match is scored more if the characters in the patterns are closer to each other, @@ -212,11 +209,6 @@ namespace Wox.Infrastructure score += 10; } - if (isFullyContained) - { - score += 20; // honestly I'm not sure what would be a good number here or should it factor the size of the pattern - } - if (allWordsFullyMatched) { score += 20;