Change uniqueDeinflectionsMap to use a real Map

This commit is contained in:
toasted-nutbread 2020-01-24 21:51:58 -05:00
parent 7357eaf07a
commit c75d04ccb7

View File

@ -290,17 +290,15 @@ class Translator {
const uniqueDeinflectionTerms = []; const uniqueDeinflectionTerms = [];
const uniqueDeinflectionArrays = []; const uniqueDeinflectionArrays = [];
const uniqueDeinflectionsMap = {}; const uniqueDeinflectionsMap = new Map();
for (const deinflection of deinflections) { for (const deinflection of deinflections) {
const term = deinflection.term; const term = deinflection.term;
let deinflectionArray; let deinflectionArray = uniqueDeinflectionsMap.get(term);
if (hasOwn(uniqueDeinflectionsMap, term)) { if (typeof deinflectionArray === 'undefined') {
deinflectionArray = uniqueDeinflectionsMap[term];
} else {
deinflectionArray = []; deinflectionArray = [];
uniqueDeinflectionTerms.push(term); uniqueDeinflectionTerms.push(term);
uniqueDeinflectionArrays.push(deinflectionArray); uniqueDeinflectionArrays.push(deinflectionArray);
uniqueDeinflectionsMap[term] = deinflectionArray; uniqueDeinflectionsMap.set(term, deinflectionArray);
} }
deinflectionArray.push(deinflection); deinflectionArray.push(deinflection);
} }