Queue: remove FindUri(mpd_song)
authorMax Kellermann <max@musicpd.org>
Tue, 4 Sep 2018 08:24:47 +0000 (10:24 +0200)
committerMax Kellermann <max@musicpd.org>
Tue, 4 Sep 2018 08:24:47 +0000 (10:24 +0200)
This overload appears to be convenient, but it is somewhat confusing,
because there is also FindByReference().

src/FileListPage.cxx
src/Queue.hxx

index 6f4ff18..e6e1e16 100644 (file)
@@ -65,7 +65,7 @@ screen_browser_sync_highlights(FileList *fl, const MpdQueue *playlist)
                if (entity != nullptr && mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
                        const auto *song = mpd_entity_get_song(entity);
 
-                       if (playlist->FindByUri(*song) >= 0)
+                       if (playlist->FindByUri(mpd_song_get_uri(song)) >= 0)
                                entry.flags |= HIGHLIGHT;
                        else
                                entry.flags &= ~HIGHLIGHT;
@@ -142,7 +142,7 @@ enqueue_and_play(struct mpdclient *c, FileListEntry *entry)
                id = -1;
        else
 #endif
-               id = c->playlist.FindIdByUri(*song);
+               id = c->playlist.FindIdByUri(mpd_song_get_uri(song));
 
        if (id < 0) {
                char buf[BUFSIZE];
@@ -279,7 +279,7 @@ browser_select_entry(struct mpdclient *c, FileListEntry *entry,
 
                entry->flags &= ~HIGHLIGHT;
 
-               while ((idx = c->playlist.FindByUri(*song)) >= 0)
+               while ((idx = c->playlist.FindByUri(mpd_song_get_uri(song))) >= 0)
                        mpdclient_cmd_delete(c, idx);
 #endif
        }
index 76f0630..ae6b1ee 100644 (file)
@@ -112,27 +112,14 @@ struct MpdQueue {
        gcc_pure
        int FindByUri(const char *uri) const;
 
-       /**
-        * Find a song by its URI (obtained from another #mpd_song
-        * instance).  Unlike FindByReference(), the given #mpd_song
-        * does not need to be obtained from this container.
-        *
-        * @return the song position
-        */
-       gcc_pure
-       int FindByUri(const struct mpd_song &song) const {
-               return FindByUri(mpd_song_get_uri(&song));
-       }
-
        /**
         * Like FindByUri(), but return the song id, not the song position
         *
         * @return the song id
         */
-       template<typename U>
        gcc_pure
-       int FindIdByUri(U &&uri) const {
-               int i = FindByUri(std::forward<U>(uri));
+       int FindIdByUri(const char *uri) const {
+               int i = FindByUri(uri);
                if (i >= 0)
                        i = mpd_song_get_id(items[i].get());
                return i;