1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-05 22:14:55 +00:00

AK/FuzzyMatch: Use a first letter bonus of 15 rather than 20

This matches the value used in the original `lib_fts` implementation
of the algorithm.
This commit is contained in:
Tim Ledbetter 2023-09-29 17:36:19 +01:00 committed by Andreas Kling
parent 9fefb434f2
commit 292017d7bd

View File

@ -17,7 +17,7 @@ static constexpr int const MAX_MATCHES = 256;
static constexpr int const SEQUENTIAL_BONUS = 15; // bonus for adjacent matches (needle: 'ca', haystack: 'cat')
static constexpr int const SEPARATOR_BONUS = 30; // bonus if match occurs after a separator ('_' or ' ')
static constexpr int const CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower (needle: 'myF' haystack: '/path/to/myFile.txt')
static constexpr int const FIRST_LETTER_BONUS = 20; // bonus if the first letter is matched (needle: 'c' haystack: 'cat')
static constexpr int const FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched (needle: 'c' haystack: 'cat')
static constexpr int const LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match
static constexpr int const MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters
static constexpr int const UNMATCHED_LETTER_PENALTY = -1; // penalty for every letter that doesn't matter