Bug 1613314 - Lazily create the UrlbarProviderInterventions QueryScorer. r=harry

Differential Revision: https://phabricator.services.mozilla.com/D61751

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Drew Willcoxon 2020-02-06 12:19:19 +00:00
Родитель c8f08e0930
Коммит 785f16ad9f
1 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -434,22 +434,23 @@ class ProviderInterventions extends UrlbarProvider {
// The tip we should currently show.
this.currentTip = TIPS.NONE;
// Object used to match the user's queries to tips.
this.queryScorer = new QueryScorer({
variations: new Map([
// Recognize "fire fox", "fox fire", and "foxfire" as "firefox".
["firefox", ["fire fox", "fox fire", "foxfire"]],
// Recognize "mozila" as "mozilla". This will catch common mispellings
// "mozila", "mozzila", and "mozzilla" (among others) due to the edit
// distance threshold of 1.
["mozilla", ["mozila"]],
]),
// This object is used to match the user's queries to tips.
XPCOMUtils.defineLazyGetter(this, "queryScorer", () => {
let queryScorer = new QueryScorer({
variations: new Map([
// Recognize "fire fox", "fox fire", and "foxfire" as "firefox".
["firefox", ["fire fox", "fox fire", "foxfire"]],
// Recognize "mozila" as "mozilla". This will catch common mispellings
// "mozila", "mozzila", and "mozzilla" (among others) due to the edit
// distance threshold of 1.
["mozilla", ["mozila"]],
]),
});
for (let [id, phrases] of Object.entries(DOCUMENTS)) {
queryScorer.addDocument({ id, phrases });
}
return queryScorer;
});
// Initialize the query scorer.
for (let [id, phrases] of Object.entries(DOCUMENTS)) {
this.queryScorer.addDocument({ id, phrases });
}
}
/**