core/playlists/system: Compare playlist names in a loop

This is easier to maintain than a giant switch statement, and should
make it easier to add new playlist types in the future.

Implements #61: Clean up system playlists
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-07-25 11:53:10 -04:00
parent d3e2f069fd
commit b3750aa31c
1 changed files with 8 additions and 13 deletions

View File

@ -299,20 +299,15 @@ static struct sys_playlist *sys_playlists[SYS_PL_NUM_PLAYLISTS] = {
static struct sys_playlist * __sys_pl_lookup(const gchar *name)
{
if (string_match(name, "Favorites"))
return &sys_favorites;
else if (string_match(name, "Hidden") || string_match(name, "Banned"))
unsigned int i;
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++) {
if (string_match(name, sys_playlists[i]->spl_playlist.pl_name))
return sys_playlists[i];
}
if (string_match(name, "Banned"))
return &sys_hidden;
else if (string_match(name, "Collection"))
return &sys_collection;
else if (string_match(name, "History"))
return &sys_history;
else if (string_match(name, "Unplayed"))
return &sys_unplayed;
else if (string_match(name, "Most Played"))
return &sys_most_played;
else if (string_match(name, "Least Played"))
return &sys_least_played;
return NULL;
}