summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/dictionary.js11
-rw-r--r--ext/bg/js/translator.js8
-rw-r--r--ext/fg/js/document.js4
3 files changed, 12 insertions, 11 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 49afc368..498eafcd 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -140,16 +140,17 @@ function dictTermsCompressTags(definitions) {
function dictTermsGroup(definitions, dictionaries) {
const groups = {};
for (const definition of definitions) {
- const key = [definition.source, definition.expression].concat(definition.reasons);
+ const key = [definition.source, definition.expression];
+ key.push(...definition.reasons);
if (definition.reading) {
key.push(definition.reading);
}
- const group = groups[key];
- if (group) {
- group.push(definition);
+ const keyString = key.toString();
+ if (groups.hasOwnProperty(keyString)) {
+ groups[keyString].push(definition);
} else {
- groups[key] = [definition];
+ groups[keyString] = [definition];
}
}
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index c6af1f4e..e9e388f3 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -186,7 +186,7 @@ class Translator {
let deinflections = await this.findTermDeinflections(text, titles, cache);
const textHiragana = jpKatakanaToHiragana(text);
if (text !== textHiragana) {
- deinflections = deinflections.concat(await this.findTermDeinflections(textHiragana, titles, cache));
+ deinflections.push(...await this.findTermDeinflections(textHiragana, titles, cache));
}
let definitions = [];
@@ -235,7 +235,7 @@ class Translator {
let deinflections = [];
for (let i = text.length; i > 0; --i) {
const textSlice = text.slice(0, i);
- deinflections = deinflections.concat(await this.deinflector.deinflect(textSlice, definer));
+ deinflections.push(...await this.deinflector.deinflect(textSlice, definer));
}
return deinflections;
@@ -247,7 +247,7 @@ class Translator {
const titles = Object.keys(dictionaries);
for (const c of text) {
if (!processed[c]) {
- definitions = definitions.concat(await this.database.findKanji(c, titles));
+ definitions.push(...await this.database.findKanji(c, titles));
processed[c] = true;
}
}
@@ -277,7 +277,7 @@ class Translator {
async buildTermFrequencies(definition, titles) {
let terms = [];
if (definition.expressions) {
- terms = terms.concat(definition.expressions);
+ terms.push(...definition.expressions);
} else {
terms.push(definition);
}
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index bd876e5d..60b1b9bd 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -152,7 +152,7 @@ function docSentenceExtract(source, extent) {
if (quoteStack.length > 0 && c === quoteStack[0]) {
quoteStack.pop();
} else if (c in quotesBwd) {
- quoteStack = [quotesBwd[c]].concat(quoteStack);
+ quoteStack.unshift(quotesBwd[c]);
}
}
@@ -181,7 +181,7 @@ function docSentenceExtract(source, extent) {
if (quoteStack.length > 0 && c === quoteStack[0]) {
quoteStack.pop();
} else if (c in quotesFwd) {
- quoteStack = [quotesFwd[c]].concat(quoteStack);
+ quoteStack.unshift(quotesFwd[c]);
}
}