summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 12:30:07 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-22 14:36:07 -0500
commit886278b19de3693f75bb6c7775da8db86a8dd008 (patch)
tree53a27923b3bcd0595866ba31fd42de567328f306 /ext/bg/js/translator.js
parent452eec8a881f0fcbdb2d5c75ae8253b158812d10 (diff)
Use Set
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js10
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 3471cb01..b850c6e4 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -400,16 +400,12 @@ class Translator {
async findKanji(text, options) {
const dictionaries = dictEnabledSet(options);
const titles = Object.keys(dictionaries);
- const kanjiUnique = {};
- const kanjiList = [];
+ const kanjiUnique = new Set();
for (const c of text) {
- if (!hasOwn(kanjiUnique, c)) {
- kanjiList.push(c);
- kanjiUnique[c] = true;
- }
+ kanjiUnique.add(c);
}
- const definitions = await this.database.findKanjiBulk(kanjiList, titles);
+ const definitions = await this.database.findKanjiBulk([...kanjiUnique], titles);
if (definitions.length === 0) {
return definitions;
}