summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-15 17:00:01 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-22 14:43:06 -0500
commit50a171bc75f3329fec9d0aa24c4838f675a1b66d (patch)
tree8ad0b17529c11b848c7e8a9691eb1fd89a2263cb /ext/bg/js/dictionary.js
parent89af73b61b04c9bf9042aec6bad9539492a4233c (diff)
Simplify update of mergedIndices
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js27
1 files 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;
}
}