From 50a171bc75f3329fec9d0aa24c4838f675a1b66d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 15 Feb 2020 17:00:01 -0500 Subject: Simplify update of mergedIndices --- ext/bg/js/dictionary.js | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 5a85bb5b..532d17c7 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -178,26 +178,15 @@ function dictTermsMergeBySequence(definitions, mainDictionary) { function dictTermsMergeByGloss(result, definitions, appendTo=null, mergedIndices=null) { const definitionsByGloss = appendTo !== null ? appendTo : new Map(); for (const [index, definition] of definitions.entries()) { - if (appendTo !== null) { - let match = false; - for (const expression of result.expressions.keys()) { - if (definition.expression === expression) { - for (const reading of result.expressions.get(expression).keys()) { - if (definition.reading === reading) { - match = true; - break; - } - } - } - if (match) { - break; - } - } - - if (!match) { - continue; - } else if (mergedIndices !== null) { + if (mergedIndices !== null) { + const expressionMap = result.expressions.get(definition.expression); + if ( + typeof expressionMap !== 'undefined' && + typeof expressionMap.get(definition.reading) !== 'undefined' + ) { mergedIndices.add(index); + } else { + continue; } } -- cgit v1.2.3