From 8cad20585dbbf5987d6649bea9c6b6ba688b7bff Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Jan 2013 18:51:40 +0100 Subject: playlist/memory: use std::forward_list instead of GSList --- src/playlist/RssPlaylistPlugin.cxx | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/playlist/RssPlaylistPlugin.cxx') diff --git a/src/playlist/RssPlaylistPlugin.cxx b/src/playlist/RssPlaylistPlugin.cxx index 1c714a965..3b69202e6 100644 --- a/src/playlist/RssPlaylistPlugin.cxx +++ b/src/playlist/RssPlaylistPlugin.cxx @@ -40,7 +40,7 @@ struct RssParser { * The list of songs (in reverse order because that's faster * while adding). */ - GSList *songs; + std::forward_list songs; /** * The current position in the XML file. @@ -63,7 +63,7 @@ struct RssParser { struct song *song; RssParser() - :songs(nullptr), state(ROOT) {} + :state(ROOT) {} }; static const gchar * @@ -140,8 +140,7 @@ rss_end_element(G_GNUC_UNUSED GMarkupParseContext *context, case RssParser::ITEM: if (g_ascii_strcasecmp(element_name, "item") == 0) { if (strcmp(parser->song->uri, "rss:") != 0) - parser->songs = g_slist_prepend(parser->songs, - parser->song); + parser->songs.emplace_front(parser->song); else song_free(parser->song); @@ -184,14 +183,6 @@ static const GMarkupParser rss_parser = { nullptr, }; -static void -song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data) -{ - struct song *song = (struct song *)data; - - song_free(song); -} - static void rss_parser_destroy(gpointer data) { @@ -199,9 +190,6 @@ rss_parser_destroy(gpointer data) if (parser->state >= RssParser::ITEM) song_free(parser->song); - - g_slist_foreach(parser->songs, song_free_callback, NULL); - g_slist_free(parser->songs); } /* @@ -257,11 +245,9 @@ rss_open_stream(struct input_stream *is) return NULL; } - /* create a #rss_playlist object from the parsed song list */ - + parser.songs.reverse(); MemoryPlaylistProvider *playlist = - new MemoryPlaylistProvider(g_slist_reverse(parser.songs)); - parser.songs = NULL; + new MemoryPlaylistProvider(std::move(parser.songs)); g_markup_parse_context_free(context); -- cgit v1.2.3