diff --git a/src/filelist.c b/src/filelist.c
index a8b8b3ca364b5445719873ac9c98c30078aa39ef..73cc6f3111761d32ca0e7895daec37f3fba37c7d 100644 (file)
--- a/src/filelist.c
+++ b/src/filelist.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
* Project homepage: http://musicpd.org
* This program is free software; you can redistribute it and/or modify
return entry;
}
-struct filelist_entry *
-filelist_prepend(struct filelist *filelist, struct mpd_entity *entity)
-{
- struct filelist_entry *entry = filelist_append(filelist, entity);
-
- /* this is very slow, but we should optimize screen_artist.c
- later so that this function can be removed, so I'm not in
- the mood to implement something better here */
-
- if (!filelist_is_empty(filelist)) {
- guint i;
-
- for (i = filelist_length(filelist) - 1; i > 0; --i)
- g_ptr_array_index(filelist->entries, i) =
- filelist_get(filelist, i - 1);
-
- g_ptr_array_index(filelist->entries, 0) = entry;
- }
-
- return entry;
-}
-
void
filelist_move(struct filelist *filelist, struct filelist *from)
{
filelist_compare_indirect, compare_func);
}
+void
+filelist_no_duplicates(struct filelist *filelist)
+{
+ for (int i = filelist_length(filelist) - 1; i >= 0; --i) {
+ struct filelist_entry *entry = filelist_get(filelist, i);
+ const struct mpd_song *song;
+
+ if (entry->entity == NULL ||
+ mpd_entity_get_type(entry->entity) != MPD_ENTITY_TYPE_SONG)
+ continue;
+
+ song = mpd_entity_get_song(entry->entity);
+ if (filelist_find_song(filelist, song) < i) {
+ g_ptr_array_remove_index(filelist->entries, i);
+ mpd_entity_free(entry->entity);
+ g_slice_free(struct filelist_entry, entry);
+ }
+ }
+}
+
static bool
same_song(const struct mpd_song *a, const struct mpd_song *b)
{