Skip to content

Commit

Permalink
refactor: 중복 범위 검증 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyma-s committed Nov 4, 2023
1 parent 21ce10a commit 6121790
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,25 @@ private void reorder(final Song updatedSong) {
}

private boolean shouldMoveForward(final Song song, final int index) {
if (index == 0) {
if (index <= 0) {
return false;
}

final Long prevSongId = sortedSongIds.get(index - 1);
final Song prevSong = songs.get(prevSongId);

return index > 0 && shouldSwapWithPrevious(song, prevSong);
return shouldSwapWithPrevious(song, prevSong);
}

private boolean shouldMoveBackward(final Song song, final int index) {
if (index == sortedSongIds.size() - 1) {
if (index >= sortedSongIds.size() - 1) {
return false;
}

final Long nextSongId = sortedSongIds.get(index + 1);
final Song nextSong = songs.get(nextSongId);

return index < sortedSongIds.size() - 1 && shouldSwapWithNext(song, nextSong);
return shouldSwapWithNext(song, nextSong);
}

private void moveForward(final Song changedSong, final int songIndex) {
Expand Down

0 comments on commit 6121790

Please sign in to comment.