@@ -145,17 +145,17 @@ public static int getCategoryOfFilterMatch(String documentFilter, String complet
145145 * @return score of the match where the lower the number, the better the score
146146 * and -1 mean there was no match
147147 */
148- public static int getScoreOfFilterMatch (String documentFilter , String completionFilter ) {
149- documentFilter = documentFilter .toLowerCase ();
150- completionFilter = completionFilter .toLowerCase ();
151- return getScoreOfFilterMatchHelper (0 , documentFilter , completionFilter );
148+ public static int getScoreOfFilterMatch (final String documentFilter , final String completionFilter ) {
149+ return getScoreOfFilterMatchHelper (0 , documentFilter .toLowerCase (), completionFilter .toLowerCase ());
152150 }
153151
154- private static int getScoreOfFilterMatchHelper (int prefixLength , String documentFilter , String completionFilter ) {
152+ private static int getScoreOfFilterMatchHelper (final int prefixLength , final String documentFilter ,
153+ final String completionFilter ) {
155154 if (documentFilter .isEmpty ()) {
156155 return 0 ;
157156 }
158- char searchChar = documentFilter .charAt (0 );
157+
158+ final char searchChar = documentFilter .charAt (0 );
159159 int i = completionFilter .indexOf (searchChar );
160160 if (i == -1 ) {
161161 return -1 ;
@@ -166,17 +166,10 @@ private static int getScoreOfFilterMatchHelper(int prefixLength, String document
166166 return i + prefixLength ;
167167 }
168168
169- int matchLength = commonPrefixLength (documentFilter , completionFilter .substring (i ));
170- if (matchLength == documentFilterLength ) {
171- return i + prefixLength ;
172- }
173- int bestScore = i + getScoreOfFilterMatchHelper (prefixLength + i + matchLength ,
174- documentFilter .substring (matchLength ),
175- completionFilter .substring (i + matchLength ));
169+ int bestScore = Integer .MAX_VALUE ;
176170
177- i = completionFilter .indexOf (searchChar , i + 1 );
178171 while (i != -1 ) {
179- matchLength = commonPrefixLength (documentFilter , completionFilter .substring (i ));
172+ final int matchLength = commonPrefixLength (documentFilter , completionFilter .substring (i ));
180173 if (matchLength == documentFilterLength ) {
181174 return i + prefixLength ;
182175 }
0 commit comments