From 3ca0a39a357d9be9c85de4892ac02716f8af2ae8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 10 Jun 2014 21:15:40 +0200 Subject: db/simple: use class boost::intrusive::list Remove the C list_head library and use type-safe C++ instead. --- src/db/plugins/simple/SongSort.cxx | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/db/plugins/simple/SongSort.cxx') 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 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); } -- cgit v1.2.3