diff options
author | Max Kellermann <max@duempel.org> | 2014-06-10 21:15:40 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-06-16 18:39:16 +0200 |
commit | 3ca0a39a357d9be9c85de4892ac02716f8af2ae8 (patch) | |
tree | 88c87573974f6609a1dc68cf20e5901600613280 /src/db/plugins/simple/SongSort.cxx | |
parent | 52594e64d0f48eb83c9bf54eb1ac95a6de881829 (diff) | |
download | mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.gz mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.xz mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.zip |
db/simple: use class boost::intrusive::list
Remove the C list_head library and use type-safe C++ instead.
Diffstat (limited to '')
-rw-r--r-- | src/db/plugins/simple/SongSort.cxx | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/db/plugins/simple/SongSort.cxx b/src/db/plugins/simple/SongSort.cxx index c5752f568..4b7144937 100644 --- a/src/db/plugins/simple/SongSort.cxx +++ b/src/db/plugins/simple/SongSort.cxx @@ -23,10 +23,6 @@ #include "tag/Tag.hxx" #include "lib/icu/Collate.hxx" -extern "C" { -#include "util/list_sort.h" -} - #include <stdlib.h> static int @@ -80,34 +76,33 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type) } /* Only used for sorting/searchin a songvec, not general purpose compares */ -static int -song_cmp(gcc_unused void *priv, struct list_head *_a, struct list_head *_b) +gcc_pure +static bool +song_cmp(const Song &a, const Song &b) { - const Song *a = (const Song *)_a; - const Song *b = (const Song *)_b; int ret; /* first sort by album */ - ret = compare_string_tag_item(a->tag, b->tag, TAG_ALBUM); + ret = compare_string_tag_item(a.tag, b.tag, TAG_ALBUM); if (ret != 0) - return ret; + return ret < 0; /* then sort by disc */ - ret = compare_tag_item(a->tag, b->tag, TAG_DISC); + ret = compare_tag_item(a.tag, b.tag, TAG_DISC); if (ret != 0) - return ret; + return ret < 0; /* then by track number */ - ret = compare_tag_item(a->tag, b->tag, TAG_TRACK); + ret = compare_tag_item(a.tag, b.tag, TAG_TRACK); if (ret != 0) - return ret; + return ret < 0; /* still no difference? compare file name */ - return IcuCollate(a->uri, b->uri); + return IcuCollate(a.uri, b.uri) < 0; } void -song_list_sort(struct list_head *songs) +song_list_sort(SongList &songs) { - list_sort(nullptr, songs, song_cmp); + songs.sort(song_cmp); } |