diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx index bb1776379..db85e0d32 100644 --- a/src/archive/plugins/ZzipArchivePlugin.cxx +++ b/src/archive/plugins/ZzipArchivePlugin.cxx @@ -91,7 +91,7 @@ class ZzipInputStream final : public InputStream { ZZIP_FILE *const file; public: - ZzipInputStream(const std::shared_ptr _dir, const char *_uri, + ZzipInputStream(const std::shared_ptr& _dir, const char *_uri, Mutex &_mutex, ZZIP_FILE *_file) :InputStream(_uri, _mutex), diff --git a/src/command/CommandError.cxx b/src/command/CommandError.cxx index f96932613..1b0c60fab 100644 --- a/src/command/CommandError.cxx +++ b/src/command/CommandError.cxx @@ -82,7 +82,7 @@ ToAck(DatabaseErrorCode code) noexcept gcc_pure static enum ack -ToAck(std::exception_ptr ep) noexcept +ToAck(const std::exception_ptr& ep) noexcept { try { std::rethrow_exception(ep); @@ -113,7 +113,7 @@ ToAck(std::exception_ptr ep) noexcept } void -PrintError(Response &r, std::exception_ptr ep) +PrintError(Response &r, const std::exception_ptr& ep) { LogError(ep); r.Error(ToAck(ep), GetFullMessage(ep).c_str()); diff --git a/src/command/CommandError.hxx b/src/command/CommandError.hxx index 8209135e9..5ca806899 100644 --- a/src/command/CommandError.hxx +++ b/src/command/CommandError.hxx @@ -28,6 +28,6 @@ class Response; * Send the exception to the client. */ void -PrintError(Response &r, std::exception_ptr ep); +PrintError(Response &r, const std::exception_ptr& ep); #endif 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); } 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 diff --git a/src/input/Error.cxx b/src/input/Error.cxx index 80e21c31a..b6d34091d 100644 --- a/src/input/Error.cxx +++ b/src/input/Error.cxx @@ -30,11 +30,13 @@ #include #endif +#include + bool IsFileNotFound(std::exception_ptr ep) noexcept { try { - std::rethrow_exception(ep); + std::rethrow_exception(std::move(ep)); } catch (const std::system_error &e) { return IsFileNotFound(e); #ifdef ENABLE_CURL diff --git a/src/input/plugins/QobuzInputPlugin.cxx b/src/input/plugins/QobuzInputPlugin.cxx index 85b31a1c0..3936cb371 100644 --- a/src/input/plugins/QobuzInputPlugin.cxx +++ b/src/input/plugins/QobuzInputPlugin.cxx @@ -65,7 +65,7 @@ public: } private: - void Failed(std::exception_ptr e) { + void Failed(const std::exception_ptr& e) { SetInput(std::make_unique(GetURI(), e, mutex)); } diff --git a/src/input/plugins/TidalInputPlugin.cxx b/src/input/plugins/TidalInputPlugin.cxx index 6df562047..b0c3bf9dc 100644 --- a/src/input/plugins/TidalInputPlugin.cxx +++ b/src/input/plugins/TidalInputPlugin.cxx @@ -35,6 +35,7 @@ #include "Log.hxx" #include +#include static constexpr Domain tidal_domain("tidal"); @@ -77,7 +78,7 @@ public: } private: - void Failed(std::exception_ptr e) { + void Failed(const std::exception_ptr& e) { SetInput(std::make_unique(GetURI(), e, mutex)); } @@ -133,7 +134,7 @@ static bool IsInvalidSession(std::exception_ptr e) noexcept { try { - std::rethrow_exception(e); + std::rethrow_exception(std::move(e)); } catch (const TidalError &te) { return te.IsInvalidSession(); } catch (...) { diff --git a/src/lib/upnp/ContentDirectoryService.cxx b/src/lib/upnp/ContentDirectoryService.cxx index f43a304a9..539da0fa5 100644 --- a/src/lib/upnp/ContentDirectoryService.cxx +++ b/src/lib/upnp/ContentDirectoryService.cxx @@ -37,7 +37,7 @@ ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, m_modelName(device.modelName), m_rdreqcnt(200) { - if (!m_modelName.compare("MediaTomb")) { + if (m_modelName == "MediaTomb") { // Readdir by 200 entries is good for most, but MediaTomb likes // them really big. Actually 1000 is better but I don't dare m_rdreqcnt = 500; diff --git a/src/pcm/Dop.cxx b/src/pcm/Dop.cxx index ed84e4abe..89c68d689 100644 --- a/src/pcm/Dop.cxx +++ b/src/pcm/Dop.cxx @@ -94,5 +94,5 @@ DsdToDopConverter::Convert(ConstBuffer src) noexcept { using namespace std::placeholders; return rest_buffer.Process(buffer, src, 2 * channels, - std::bind(DsdToDop, _1, _2, _3, channels)); + [=](auto && arg1, auto && arg2, auto && arg3) { return DsdToDop(arg1, arg2, arg3, channels); }); } diff --git a/src/pcm/Dsd16.cxx b/src/pcm/Dsd16.cxx index 52cef4bed..24be94570 100644 --- a/src/pcm/Dsd16.cxx +++ b/src/pcm/Dsd16.cxx @@ -65,5 +65,5 @@ Dsd16Converter::Convert(ConstBuffer src) noexcept { using namespace std::placeholders; return rest_buffer.Process(buffer, src, channels, - std::bind(Dsd8To16, _1, _2, _3, channels)); + [=](auto && arg1, auto && arg2, auto && arg3) { return Dsd8To16(arg1, arg2, arg3, channels); }); } diff --git a/src/pcm/Dsd32.cxx b/src/pcm/Dsd32.cxx index a6fd81018..81d94917c 100644 --- a/src/pcm/Dsd32.cxx +++ b/src/pcm/Dsd32.cxx @@ -67,5 +67,5 @@ Dsd32Converter::Convert(ConstBuffer src) noexcept { using namespace std::placeholders; return rest_buffer.Process(buffer, src, channels, - std::bind(Dsd8To32, _1, _2, _3, channels)); + [=](auto && arg1, auto && arg2, auto && arg3) { return Dsd8To32(arg1, arg2, arg3, channels); }); } diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx index dcf9dba35..19f881666 100644 --- a/src/tag/ApeLoader.cxx +++ b/src/tag/ApeLoader.cxx @@ -38,7 +38,7 @@ struct ApeFooter { }; bool -tag_ape_scan(InputStream &is, ApeTagCallback callback) +tag_ape_scan(InputStream &is, const ApeTagCallback& callback) try { std::unique_lock lock(is.mutex); diff --git a/src/tag/ApeLoader.hxx b/src/tag/ApeLoader.hxx index 76f34e43b..e930cb3a8 100644 --- a/src/tag/ApeLoader.hxx +++ b/src/tag/ApeLoader.hxx @@ -37,6 +37,6 @@ typedef std::function