From fc4a9614123732688cad643117abf2a047593b43 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 11 Aug 2019 14:59:02 -0400 Subject: Replace some instances of Array.concat .push or .unshift can accomplish the same operation without constructing new arrays. --- ext/bg/js/dictionary.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ext/bg/js/dictionary.js') 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]; } } -- cgit v1.2.3