From dfed9546aa784dddab8be04c676bb337c7c3d626 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 31 Jan 2020 19:54:34 -0800 Subject: [clang-tidy] replace std::bind with lambdas Found with modernize-avoid-bind Signed-off-by: Rosen Penev --- src/db/DatabasePlaylist.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/db') diff --git a/src/db/DatabasePlaylist.cxx b/src/db/DatabasePlaylist.cxx index 78a9d9b67..ae4170ffe 100644 --- a/src/db/DatabasePlaylist.cxx +++ b/src/db/DatabasePlaylist.cxx @@ -39,7 +39,6 @@ search_add_to_playlist(const Database &db, const Storage *storage, const DatabaseSelection &selection) { using namespace std::placeholders; - const auto f = std::bind(AddSong, storage, - playlist_path_utf8, _1); + const auto f = [=](auto && arg1) { return AddSong(storage, playlist_path_utf8, arg1); }; db.Visit(selection, f); } -- cgit v1.2.3 From 452c41b71fe768227a3607f8742816134120c5f9 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 31 Jan 2020 21:10:03 -0800 Subject: [clang-tidy] convert several functions to const & Found with performance-unnecessary-value-param Signed-off-by: Rosen Penev --- src/db/plugins/ProxyDatabasePlugin.cxx | 23 +++++++++++----------- src/db/plugins/simple/Directory.cxx | 4 ++-- src/db/plugins/simple/Directory.hxx | 4 ++-- src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 31 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 30 deletions(-) (limited to 'src/db') diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index c393fea72..6d77416f2 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -50,8 +50,9 @@ #include #include -#include #include +#include +#include class LibmpdclientError final : public std::runtime_error { enum mpd_error code; @@ -674,15 +675,15 @@ ProxyDatabase::ReturnSong(const LightSong *_song) const noexcept static void Visit(struct mpd_connection *connection, const char *uri, bool recursive, const SongFilter *filter, - VisitDirectory visit_directory, VisitSong visit_song, - VisitPlaylist visit_playlist); + const VisitDirectory& visit_directory, const VisitSong& visit_song, + const VisitPlaylist& visit_playlist); static void Visit(struct mpd_connection *connection, bool recursive, const SongFilter *filter, const struct mpd_directory *directory, - VisitDirectory visit_directory, VisitSong visit_song, - VisitPlaylist visit_playlist) + const VisitDirectory& visit_directory, const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) { const char *path = mpd_directory_get_path(directory); @@ -697,7 +698,7 @@ Visit(struct mpd_connection *connection, if (recursive) Visit(connection, path, recursive, filter, - visit_directory, visit_song, visit_playlist); + visit_directory, std::move(visit_song), std::move(visit_playlist)); } gcc_pure @@ -710,7 +711,7 @@ Match(const SongFilter *filter, const LightSong &song) noexcept static void Visit(const SongFilter *filter, const mpd_song *_song, - VisitSong visit_song) + const VisitSong& visit_song) { if (!visit_song) return; @@ -722,7 +723,7 @@ Visit(const SongFilter *filter, static void Visit(const struct mpd_playlist *playlist, - VisitPlaylist visit_playlist) + const VisitPlaylist& visit_playlist) { if (!visit_playlist) return; @@ -778,8 +779,8 @@ ReceiveEntities(struct mpd_connection *connection) noexcept static void Visit(struct mpd_connection *connection, const char *uri, bool recursive, const SongFilter *filter, - VisitDirectory visit_directory, VisitSong visit_song, - VisitPlaylist visit_playlist) + const VisitDirectory& visit_directory, const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) { if (!mpd_send_list_meta(connection, uri)) ThrowError(connection); @@ -813,7 +814,7 @@ Visit(struct mpd_connection *connection, const char *uri, static void SearchSongs(struct mpd_connection *connection, const DatabaseSelection &selection, - VisitSong visit_song) + const VisitSong& visit_song) try { assert(selection.recursive); assert(visit_song); diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index e478b6d06..e372c3685 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -220,8 +220,8 @@ Directory::Sort() noexcept void Directory::Walk(bool recursive, const SongFilter *filter, - VisitDirectory visit_directory, VisitSong visit_song, - VisitPlaylist visit_playlist) const + const VisitDirectory& visit_directory, const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) const { if (IsMount()) { assert(IsEmpty()); diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index 26069ec99..33d08d804 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -284,8 +284,8 @@ public: * Caller must lock #db_mutex. */ void Walk(bool recursive, const SongFilter *match, - VisitDirectory visit_directory, VisitSong visit_song, - VisitPlaylist visit_playlist) const; + const VisitDirectory& visit_directory, const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) const; gcc_pure LightDirectory Export() const noexcept; diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 6145d535e..8b1dc0213 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -41,6 +41,7 @@ #include "util/SplitString.hxx" #include +#include #include #include @@ -107,9 +108,9 @@ private: void VisitServer(const ContentDirectoryService &server, std::forward_list &&vpath, const DatabaseSelection &selection, - VisitDirectory visit_directory, - VisitSong visit_song, - VisitPlaylist visit_playlist) const; + const VisitDirectory& visit_directory, + const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) const; /** * Run an UPnP search according to MPD parameters, and @@ -118,7 +119,7 @@ private: void SearchSongs(const ContentDirectoryService &server, const char *objid, const DatabaseSelection &selection, - VisitSong visit_song) const; + const VisitSong& visit_song) const; UPnPDirContent SearchSongs(const ContentDirectoryService &server, const char *objid, @@ -311,7 +312,7 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server, static void visitSong(const UPnPDirObject &meta, const char *path, const DatabaseSelection &selection, - VisitSong visit_song) + const VisitSong& visit_song) { if (!visit_song) return; @@ -339,7 +340,7 @@ void UpnpDatabase::SearchSongs(const ContentDirectoryService &server, const char *objid, const DatabaseSelection &selection, - VisitSong visit_song) const + const VisitSong& visit_song) const { if (!visit_song) return; @@ -440,13 +441,13 @@ UpnpDatabase::Namei(const ContentDirectoryService &server, static void VisitItem(const UPnPDirObject &object, const char *uri, const DatabaseSelection &selection, - VisitSong visit_song, VisitPlaylist visit_playlist) + const VisitSong& visit_song, const VisitPlaylist& visit_playlist) { assert(object.type == UPnPDirObject::Type::ITEM); switch (object.item_class) { case UPnPDirObject::ItemClass::MUSIC: - visitSong(object, uri, selection, visit_song); + visitSong(object, uri, selection, std::move(visit_song)); break; case UPnPDirObject::ItemClass::PLAYLIST: @@ -469,9 +470,9 @@ VisitItem(const UPnPDirObject &object, const char *uri, static void VisitObject(const UPnPDirObject &object, const char *uri, const DatabaseSelection &selection, - VisitDirectory visit_directory, - VisitSong visit_song, - VisitPlaylist visit_playlist) + const VisitDirectory& visit_directory, + const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) { switch (object.type) { case UPnPDirObject::Type::UNKNOWN: @@ -486,7 +487,7 @@ VisitObject(const UPnPDirObject &object, const char *uri, case UPnPDirObject::Type::ITEM: VisitItem(object, uri, selection, - visit_song, visit_playlist); + std::move(visit_song), std::move(visit_playlist)); break; } } @@ -497,9 +498,9 @@ void UpnpDatabase::VisitServer(const ContentDirectoryService &server, std::forward_list &&vpath, const DatabaseSelection &selection, - VisitDirectory visit_directory, - VisitSong visit_song, - VisitPlaylist visit_playlist) const + const VisitDirectory& visit_directory, + const VisitSong& visit_song, + const VisitPlaylist& visit_playlist) const { /* If the path begins with rootid, we know that this is a song, not a directory (because that's how we set things -- cgit v1.2.3