Skip to content

Commit 75adfb6

Browse files
committed
Don't mutate custom instrument list in SongResampler#applyNbsTempoChangers
1 parent fb6879a commit 75adfb6

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/main/java/net/raphimc/noteblocklib/util/SongResampler.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package net.raphimc.noteblocklib.util;
1919

2020
import net.raphimc.noteblocklib.format.nbs.NbsSong;
21-
import net.raphimc.noteblocklib.format.nbs.model.NbsCustomInstrument;
2221
import net.raphimc.noteblocklib.format.nbs.model.NbsNote;
2322
import net.raphimc.noteblocklib.model.Note;
2423
import net.raphimc.noteblocklib.model.SongView;
@@ -68,14 +67,7 @@ public static void applyNbsTempoChangers(final NbsSong song) {
6867
public static void applyNbsTempoChangers(final NbsSong song, final SongView<NbsNote> view) {
6968
if (song.getHeader().getVersion() < 4) return;
7069

71-
boolean hasTempoChanger = false;
72-
for (NbsCustomInstrument customInstrument : song.getData().getCustomInstruments()) {
73-
if (customInstrument.getName().equals("Tempo Changer")) {
74-
song.getData().getCustomInstruments().remove(customInstrument);
75-
hasTempoChanger = true;
76-
break;
77-
}
78-
}
70+
final boolean hasTempoChanger = song.getData().getCustomInstruments().stream().anyMatch(ci -> ci.getName().equals("Tempo Changer"));
7971
if (!hasTempoChanger) return;
8072

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

0 commit comments

Comments
 (0)