From 886278b19de3693f75bb6c7775da8db86a8dd008 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 15 Feb 2020 12:30:07 -0500 Subject: Use Set --- ext/bg/js/translator.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'ext/bg') 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; } -- cgit v1.2.3