Skip to content

Commit 00bec0c

Browse files
committed
Remove unnecessary branches in code
Modulo operators are perfect for this type of logic.
1 parent 275bbfc commit 00bec0c

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/APlayer.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,8 @@ class APlayer {
583583
}
584584
}
585585
else if (this.mode === 'circulation') {
586-
if (this.playIndex < this.option.music.length - 1) {
587-
this.setMusic(++this.playIndex);
588-
}
589-
else {
590-
this.setMusic(0);
591-
}
586+
this.playIndex = (this.playIndex + 1) % this.option.music.length;
587+
this.setMusic(this.playIndex);
592588
}
593589
}
594590
}

0 commit comments

Comments
 (0)