From bd71d3ea78c23c9d344208c823e21cb7f900ba97 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jan 2009 00:09:29 +0100 Subject: playlist: return early from shufflePlaylist() Remove one indent level by returning diretly after the check. This makes the function more readable. --- src/playlist.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/playlist.c b/src/playlist.c index 958b6fe14..3b370f9fe 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -997,33 +997,34 @@ void shufflePlaylist(void) { unsigned i; - if (queue_length(&playlist.queue) > 1) { - if (playlist.playing) { - if (playlist.queued >= 0) - clearPlayerQueue(); - - if (playlist.current >= 0) - /* put current playing song first */ - swapSongs(0, queue_order_to_position(&playlist.queue, - playlist.current)); + if (queue_length(&playlist.queue) <= 1) + return; - if (playlist.queue.random) { - playlist.current = - queue_position_to_order(&playlist.queue, 0); - } else - playlist.current = 0; - i = 1; - } else { - i = 0; - playlist.current = -1; - } + if (playlist.playing) { + if (playlist.queued >= 0) + clearPlayerQueue(); - /* shuffle the rest of the list */ - queue_shuffle_range(&playlist.queue, i, - queue_length(&playlist.queue)); + if (playlist.current >= 0) + /* put current playing song first */ + swapSongs(0, queue_order_to_position(&playlist.queue, + playlist.current)); - incrPlaylistVersion(); + if (playlist.queue.random) { + playlist.current = + queue_position_to_order(&playlist.queue, 0); + } else + playlist.current = 0; + i = 1; + } else { + i = 0; + playlist.current = -1; } + + /* shuffle the rest of the list */ + queue_shuffle_range(&playlist.queue, i, + queue_length(&playlist.queue)); + + incrPlaylistVersion(); } enum playlist_result savePlaylist(const char *utf8file) -- cgit v1.2.3