Use Set
This commit is contained in:
parent
452eec8a88
commit
886278b19d
@ -400,16 +400,12 @@ class Translator {
|
|||||||
async findKanji(text, options) {
|
async findKanji(text, options) {
|
||||||
const dictionaries = dictEnabledSet(options);
|
const dictionaries = dictEnabledSet(options);
|
||||||
const titles = Object.keys(dictionaries);
|
const titles = Object.keys(dictionaries);
|
||||||
const kanjiUnique = {};
|
const kanjiUnique = new Set();
|
||||||
const kanjiList = [];
|
|
||||||
for (const c of text) {
|
for (const c of text) {
|
||||||
if (!hasOwn(kanjiUnique, c)) {
|
kanjiUnique.add(c);
|
||||||
kanjiList.push(c);
|
|
||||||
kanjiUnique[c] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const definitions = await this.database.findKanjiBulk(kanjiList, titles);
|
const definitions = await this.database.findKanjiBulk([...kanjiUnique], titles);
|
||||||
if (definitions.length === 0) {
|
if (definitions.length === 0) {
|
||||||
return definitions;
|
return definitions;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user