summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c7ca92)
raw | patch | inline | side by side (parent: 6c7ca92)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 16:35:44 +0000 (18:35 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 16:35:44 +0000 (18:35 +0200) |
"continue" the loop when one condition fails. This simplifies the
"if" conditions.
"if" conditions.
src/utils.c | patch | blob | history |
diff --git a/src/utils.c b/src/utils.c
index 7864132a2514158b937451cd926658dcc037c268..49f3c63fa21e24557807304d712e133569b590b6 100644 (file)
--- a/src/utils.c
+++ b/src/utils.c
for (i = 0; i < filelist_length(filelist); ++i) {
const struct mpd_entity *entity =
filelist_get(filelist, i)->entity;
- char *name = NULL;
+ char *name;
- if (entity != NULL &&
- mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY &&
+ if (entity == NULL)
+ continue;
+
+ if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY &&
types & GCMP_TYPE_DIR) {
const struct mpd_directory *dir =
mpd_entity_get_directory(entity);
g_strlcpy(name, tmp, size);
g_strlcat(name, "/", size);
g_free(tmp);
- } else if (entity != NULL &&
- mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG &&
+ } else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG &&
types & GCMP_TYPE_FILE) {
const struct mpd_song *song =
mpd_entity_get_song(entity);
name = utf8_to_locale(mpd_song_get_uri(song));
- } else if (entity != NULL &&
- mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_PLAYLIST &&
+ } else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_PLAYLIST &&
types & GCMP_TYPE_PLAYLIST) {
const struct mpd_playlist *playlist =
mpd_entity_get_playlist(entity);
name = utf8_to_locale(mpd_playlist_get_path(playlist));
- }
+ } else
+ continue;
- if (name)
- list = g_list_append(list, name);
+ list = g_list_append(list, name);
}
filelist_free(filelist);