aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-28 16:04:55 -0400
committerGitHub <noreply@github.com>2021-03-28 16:04:55 -0400
commitf58b4962f124d8cba5378b77040ac7962a9c20a5 (patch)
tree29267ab24d9e81a041ff5f7679245a2a628c21fb
parentb4d6a5d3b4b83c7c3c7f835f775d3207a4b97067 (diff)
Remove repeated disambiguations (#1572)
-rw-r--r--ext/js/language/dictionary-data-util.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/js/language/dictionary-data-util.js b/ext/js/language/dictionary-data-util.js
index f44b81c5..3f096b02 100644
--- a/ext/js/language/dictionary-data-util.js
+++ b/ext/js/language/dictionary-data-util.js
@@ -172,8 +172,19 @@ class DictionaryDataUtil {
}
const disambiguations = [];
- if (!this._areSetsEqual(terms, allTermsSet)) { disambiguations.push(...this._getSetIntersection(terms, allTermsSet)); }
- if (!this._areSetsEqual(readings, allReadingsSet)) { disambiguations.push(...this._getSetIntersection(readings, allReadingsSet)); }
+ const addTerms = !this._areSetsEqual(terms, allTermsSet);
+ const addReadings = !this._areSetsEqual(readings, allReadingsSet);
+ if (addTerms) {
+ disambiguations.push(...this._getSetIntersection(terms, allTermsSet));
+ }
+ if (addReadings) {
+ if (addTerms) {
+ for (const term of terms) {
+ readings.delete(term);
+ }
+ }
+ disambiguations.push(...this._getSetIntersection(readings, allReadingsSet));
+ }
return disambiguations;
}