Skip to content

Commit

Permalink
Break out of infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Aug 10, 2022
1 parent d07d9d2 commit f5e8b8e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/musicxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,12 +830,18 @@ export class MusicXML {
else {
// Distribute free beats among the chords, except for short chords.
let chordIndex = 0;
let hasBeatsChangedInACycle = false;
while (beats < this.time.beats) {
if (!measure.chords[chordIndex].short) {
measure.chords[chordIndex].spaces++;
beats++;
hasBeatsChangedInACycle = true;
}
chordIndex = (chordIndex + 1) % measure.chords.length;
if (chordIndex === 0 && !hasBeatsChangedInACycle) {
// We've made a complete cycle and beat count has not changed - break now.
break;
}
}
}

Expand Down

0 comments on commit f5e8b8e

Please sign in to comment.