aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-24 21:57:01 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-24 21:57:01 -0500
commit632765a3b5b101f4533eb0fd280f5e6d68a091c9 (patch)
tree915954d8e656f7d5dd17b344048565b761eea6d2 /ext/bg/js
parentc75d04ccb771d369f92b5399e00533ae69dd4c44 (diff)
Change termsUniqueMap to use a real map
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 8a58e224..9659798c 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -453,20 +453,21 @@ class Translator {
// Create mapping of unique terms
const expressionsUnique = [];
const termsUnique = [];
- const termsUniqueMap = {};
+ const termsUniqueMap = new Map();
for (let i = 0, ii = terms.length; i < ii; ++i) {
const term = terms[i];
const expression = term.expression;
- term.frequencies = [];
-
- if (hasOwn(termsUniqueMap, expression)) {
- termsUniqueMap[expression].push(term);
- } else {
- const termList = [term];
+ let termList = termsUniqueMap.get(expression);
+ if (typeof termList === 'undefined') {
+ termList = [];
expressionsUnique.push(expression);
termsUnique.push(termList);
termsUniqueMap[expression] = termList;
}
+ termList.push(term);
+
+ // New data
+ term.frequencies = [];
}
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);