Remove unnecessary branches in code
Modulo operators are perfect for this type of logic.
This commit is contained in:
parent
275bbfcd07
commit
00bec0c66e
|
|
@ -583,12 +583,8 @@ class APlayer {
|
|||
}
|
||||
}
|
||||
else if (this.mode === 'circulation') {
|
||||
if (this.playIndex < this.option.music.length - 1) {
|
||||
this.setMusic(++this.playIndex);
|
||||
}
|
||||
else {
|
||||
this.setMusic(0);
|
||||
}
|
||||
this.playIndex = (this.playIndex + 1) % this.option.music.length;
|
||||
this.setMusic(this.playIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue