Use a Set instead of an array (#1463)

This commit is contained in:
toasted-nutbread 2021-02-28 13:33:33 -05:00 committed by GitHub
parent 445f87ebdb
commit 6f76645f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -724,15 +724,15 @@ class DisplayGenerator {
_getPitchAccentCategories(pitches) {
if (pitches.length === 0) { return null; }
const categories = [];
const categories = new Set();
for (const {reading, pitches: pitches2} of pitches) {
for (const {position} of pitches2) {
const category = this._japaneseUtil.getPitchCategory(reading, position, false);
if (category !== null) {
categories.push(category);
categories.add(category);
}
}
}
return categories.length > 0 ? categories.join(' ') : null;
return categories.size > 0 ? [...categories].join(' ') : null;
}
}