Skip to content

Commit

Permalink
Don't mutate custom instrument list in SongResampler#applyNbsTempoCha…
Browse files Browse the repository at this point in the history
…ngers
  • Loading branch information
RaphiMC committed Jun 30, 2024
1 parent fb6879a commit 75adfb6
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/main/java/net/raphimc/noteblocklib/util/SongResampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package net.raphimc.noteblocklib.util;

import net.raphimc.noteblocklib.format.nbs.NbsSong;
import net.raphimc.noteblocklib.format.nbs.model.NbsCustomInstrument;
import net.raphimc.noteblocklib.format.nbs.model.NbsNote;
import net.raphimc.noteblocklib.model.Note;
import net.raphimc.noteblocklib.model.SongView;
Expand Down Expand Up @@ -68,14 +67,7 @@ public static void applyNbsTempoChangers(final NbsSong song) {
public static void applyNbsTempoChangers(final NbsSong song, final SongView<NbsNote> view) {
if (song.getHeader().getVersion() < 4) return;

boolean hasTempoChanger = false;
for (NbsCustomInstrument customInstrument : song.getData().getCustomInstruments()) {
if (customInstrument.getName().equals("Tempo Changer")) {
song.getData().getCustomInstruments().remove(customInstrument);
hasTempoChanger = true;
break;
}
}
final boolean hasTempoChanger = song.getData().getCustomInstruments().stream().anyMatch(ci -> ci.getName().equals("Tempo Changer"));
if (!hasTempoChanger) return;

final List<TempoEvent> tempoEvents = new ArrayList<>();
Expand Down

0 comments on commit 75adfb6

Please sign in to comment.