Skip to content

Commit 8dea47b

Browse files
committed
Earlier cutoff in package name index.
1 parent b5584bd commit 8dea47b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

app/lib/search/mem_index.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,23 @@ class PackageNameIndex {
519519
continue;
520520
}
521521
var matched = 0;
522+
var unmatched = 0;
523+
final acceptThreshold = parts.length ~/ 2;
524+
final rejectThreshold = parts.length - acceptThreshold;
522525
for (final part in parts) {
523526
if (entry.trigrams.contains(part)) {
524527
matched++;
528+
} else {
529+
unmatched++;
530+
if (unmatched > rejectThreshold) {
531+
// we have no chance to accept this hit
532+
break;
533+
}
525534
}
526535
}
527536

528-
// making sure that match score is minimum 0.5
529-
if (matched > 0) {
537+
if (matched >= acceptThreshold) {
538+
// making sure that match score is minimum 0.5
530539
final v = matched / parts.length;
531540
if (v >= 0.5) {
532541
score.setValue(i, v);

0 commit comments

Comments
 (0)