FileBrowserPage: convert pointers to references
authorMax Kellermann <max@musicpd.org>
Thu, 23 Jan 2020 19:39:44 +0000 (20:39 +0100)
committerMax Kellermann <max@musicpd.org>
Thu, 23 Jan 2020 19:39:44 +0000 (20:39 +0100)
src/FileBrowserPage.cxx
src/FileListPage.cxx
src/FileListPage.hxx
src/LibraryPage.cxx
src/SearchPage.cxx

index 9d04c5a..64f08f3 100644 (file)
@@ -84,17 +84,17 @@ public:
 
 static void
 screen_file_load_list(struct mpdclient *c, const char *current_path,
-                     FileList *filelist)
+                     FileList &filelist) noexcept
 {
        auto *connection = c->GetConnection();
        if (connection == nullptr)
                return;
 
        mpd_send_list_meta(connection, current_path);
-       filelist->Receive(*connection);
+       filelist.Receive(*connection);
 
        if (c->FinishCommand())
-               filelist->Sort();
+               filelist.Sort();
 }
 
 void
@@ -107,7 +107,7 @@ FileBrowserPage::Reload(struct mpdclient &c)
                /* add a dummy entry for ./.. */
                filelist->emplace_back(nullptr);
 
-       screen_file_load_list(&c, current_path.c_str(), filelist);
+       screen_file_load_list(&c, current_path.c_str(), *filelist);
 
        lw.SetLength(filelist->size());
 
@@ -121,7 +121,7 @@ FileBrowserPage::ChangeDirectory(struct mpdclient &c, std::string &&new_path)
 
        Reload(c);
 
-       screen_browser_sync_highlights(filelist, &c.playlist);
+       screen_browser_sync_highlights(*filelist, c.playlist);
 
        lw.Reset();
 
@@ -315,7 +315,7 @@ FileBrowserPage::Update(struct mpdclient &c, unsigned events) noexcept
                      | MPD_IDLE_QUEUE
 #endif
                      )) {
-               screen_browser_sync_highlights(filelist, &c.playlist);
+               screen_browser_sync_highlights(*filelist, c.playlist);
                SetDirty();
        }
 }
@@ -345,7 +345,7 @@ FileBrowserPage::OnCommand(struct mpdclient &c, Command cmd)
 
        case Command::SCREEN_UPDATE:
                Reload(c);
-               screen_browser_sync_highlights(filelist, &c.playlist);
+               screen_browser_sync_highlights(*filelist, c.playlist);
                return false;
 
        default:
index dd597f1..64df2c6 100644 (file)
@@ -57,16 +57,16 @@ FileListPage::~FileListPage() noexcept
 
 /* sync highlight flags with playlist */
 void
-screen_browser_sync_highlights(FileList *fl, const MpdQueue *playlist)
+screen_browser_sync_highlights(FileList &fl, const MpdQueue &playlist) noexcept
 {
-       for (unsigned i = 0; i < fl->size(); ++i) {
-               auto &entry = (*fl)[i];
+       for (unsigned i = 0; i < fl.size(); ++i) {
+               auto &entry = fl[i];
                const auto *entity = entry.entity;
 
                if (entity != nullptr && mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
                        const auto *song = mpd_entity_get_song(entity);
 
-                       if (playlist->ContainsUri(mpd_song_get_uri(song)))
+                       if (playlist.ContainsUri(mpd_song_get_uri(song)))
                                entry.flags |= HIGHLIGHT;
                        else
                                entry.flags &= ~HIGHLIGHT;
index 446353e..6ff6fba 100644 (file)
@@ -97,14 +97,13 @@ public:
 #ifndef NCMPC_MINI
 
 void
-screen_browser_sync_highlights(FileList *fl,
-                              const MpdQueue *playlist);
+screen_browser_sync_highlights(FileList &fl,
+                              const MpdQueue &playlist) noexcept;
 
 #else
 
 static inline void
-screen_browser_sync_highlights(gcc_unused FileList *fl,
-                              gcc_unused const MpdQueue *playlist)
+screen_browser_sync_highlights(FileList &, const MpdQueue &) noexcept
 {
 }
 
index a043e13..ee83ef9 100644 (file)
@@ -160,7 +160,7 @@ SongListPage::LoadSongList(struct mpdclient &c)
        }
 
        /* fix highlights */
-       screen_browser_sync_highlights(filelist, &c.playlist);
+       screen_browser_sync_highlights(*filelist, c.playlist);
        lw.SetLength(filelist->size());
 }
 
index fa1a20f..e90a7a0 100644 (file)
@@ -350,7 +350,7 @@ SearchPage::Reload(struct mpdclient &c)
                filelist = new FileList();
        lw.SetLength(filelist->size());
 
-       screen_browser_sync_highlights(filelist, &c.playlist);
+       screen_browser_sync_highlights(*filelist, c.playlist);
 
        SetDirty();
 }
@@ -413,7 +413,7 @@ void
 SearchPage::Update(struct mpdclient &c, unsigned events) noexcept
 {
        if (filelist != nullptr && events & MPD_IDLE_QUEUE) {
-               screen_browser_sync_highlights(filelist, &c.playlist);
+               screen_browser_sync_highlights(*filelist, c.playlist);
                SetDirty();
        }
 }