Change termsUniqueMap to use a real map
This commit is contained in:
parent
c75d04ccb7
commit
632765a3b5
@ -453,20 +453,21 @@ class Translator {
|
|||||||
// Create mapping of unique terms
|
// Create mapping of unique terms
|
||||||
const expressionsUnique = [];
|
const expressionsUnique = [];
|
||||||
const termsUnique = [];
|
const termsUnique = [];
|
||||||
const termsUniqueMap = {};
|
const termsUniqueMap = new Map();
|
||||||
for (let i = 0, ii = terms.length; i < ii; ++i) {
|
for (let i = 0, ii = terms.length; i < ii; ++i) {
|
||||||
const term = terms[i];
|
const term = terms[i];
|
||||||
const expression = term.expression;
|
const expression = term.expression;
|
||||||
term.frequencies = [];
|
let termList = termsUniqueMap.get(expression);
|
||||||
|
if (typeof termList === 'undefined') {
|
||||||
if (hasOwn(termsUniqueMap, expression)) {
|
termList = [];
|
||||||
termsUniqueMap[expression].push(term);
|
|
||||||
} else {
|
|
||||||
const termList = [term];
|
|
||||||
expressionsUnique.push(expression);
|
expressionsUnique.push(expression);
|
||||||
termsUnique.push(termList);
|
termsUnique.push(termList);
|
||||||
termsUniqueMap[expression] = termList;
|
termsUniqueMap[expression] = termList;
|
||||||
}
|
}
|
||||||
|
termList.push(term);
|
||||||
|
|
||||||
|
// New data
|
||||||
|
term.frequencies = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);
|
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);
|
||||||
|
Loading…
Reference in New Issue
Block a user