diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-08-11 14:59:02 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-02 20:25:30 -0400 |
commit | fc4a9614123732688cad643117abf2a047593b43 (patch) | |
tree | 7d0c8aac295ad833918822412d7d359eb2be7714 /ext/bg/js/dictionary.js | |
parent | 4ac55da7dd5354e6c3495f04583352d0d863b7b6 (diff) |
Replace some instances of Array.concat
.push or .unshift can accomplish the same operation without constructing new arrays.
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r-- | ext/bg/js/dictionary.js | 11 |
1 files changed, 6 insertions, 5 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]; } } |