aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-09-05 19:46:14 -0700
committerGitHub <noreply@github.com>2019-09-05 19:46:14 -0700
commit6dc44e3f33d6f2ac2b5b7442879631a2943fcadc (patch)
treeeaac78e153efeb2a4496bd14f0c18a5d11d61d24 /ext/bg/js/dictionary.js
parent9cd0101b62fe99d736b4e6b9072c2aa4827311af (diff)
parentb90dea0e6dd9e8321ca616f256d8d88fb3c599d1 (diff)
Merge pull request #202 from toasted-nutbread/temporary-object-optimization
Temporary object optimization
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js11
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];
}
}