Remove unnecessary branches in code

Modulo operators are perfect for this type of logic.
This commit is contained in:
Eric Robinson 2017-12-12 11:55:39 -05:00
parent 275bbfcd07
commit 00bec0c66e
1 changed files with 2 additions and 6 deletions

View File

@ -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);
}
}
}