diff options
author | Max Kellermann <max@duempel.org> | 2013-01-29 18:51:40 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-29 20:32:54 +0100 |
commit | 8cad20585dbbf5987d6649bea9c6b6ba688b7bff (patch) | |
tree | b93e9dbd1e3f6e8f895ea53b2d5bfec09e6fab46 /src/playlist/AsxPlaylistPlugin.cxx | |
parent | a8b75dc4df3bf3ba9a1554249cf6d07527184864 (diff) |
playlist/memory: use std::forward_list instead of GSList
Diffstat (limited to 'src/playlist/AsxPlaylistPlugin.cxx')
-rw-r--r-- | src/playlist/AsxPlaylistPlugin.cxx | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/playlist/AsxPlaylistPlugin.cxx b/src/playlist/AsxPlaylistPlugin.cxx index db571417c..25319ca6b 100644 --- a/src/playlist/AsxPlaylistPlugin.cxx +++ b/src/playlist/AsxPlaylistPlugin.cxx @@ -40,7 +40,7 @@ struct AsxParser { * The list of songs (in reverse order because that's faster * while adding). */ - GSList *songs; + std::forward_list<SongPointer> songs; /** * The current position in the XML file. @@ -63,8 +63,7 @@ struct AsxParser { struct song *song; AsxParser() - :songs(nullptr), - state(ROOT) {} + :state(ROOT) {} }; @@ -144,8 +143,7 @@ asx_end_element(G_GNUC_UNUSED GMarkupParseContext *context, case AsxParser::ENTRY: if (g_ascii_strcasecmp(element_name, "entry") == 0) { if (strcmp(parser->song->uri, "asx:") != 0) - parser->songs = g_slist_prepend(parser->songs, - parser->song); + parser->songs.emplace_front(parser->song); else song_free(parser->song); @@ -189,23 +187,12 @@ static const GMarkupParser asx_parser = { }; static void -song_free_callback(gpointer data, G_GNUC_UNUSED gpointer user_data) -{ - struct song *song = (struct song *)data; - - song_free(song); -} - -static void asx_parser_destroy(gpointer data) { AsxParser *parser = (AsxParser *)data; if (parser->state >= AsxParser::ENTRY) song_free(parser->song); - - g_slist_foreach(parser->songs, song_free_callback, NULL); - g_slist_free(parser->songs); } /* @@ -261,11 +248,9 @@ asx_open_stream(struct input_stream *is) return NULL; } - /* create a #AsxPlaylist 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); |