From 437887ca377d592ea22af56044747bac6f75759b Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 12 Nov 2018 01:51:05 +0100 Subject: [PATCH] pass add_torrent_params by const reference in deprecated add_magnet_uri functions. They are large to copy but since they're deprecated aren't worth the trouble of having an rvalue reference overload --- include/libtorrent/magnet_uri.hpp | 4 ++-- src/magnet_uri.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index 96307a6db..32b6cd948 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -66,13 +66,13 @@ namespace libtorrent { // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url TORRENT_DEPRECATED_EXPORT torrent_handle add_magnet_uri(session& ses, std::string const& uri - , add_torrent_params p); + , add_torrent_params const& p); #endif // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url TORRENT_DEPRECATED_EXPORT torrent_handle add_magnet_uri(session& ses, std::string const& uri - , add_torrent_params p, error_code& ec); + , add_torrent_params const& p, error_code& ec); #endif // TORRENT_ABI_VERSION diff --git a/src/magnet_uri.cpp b/src/magnet_uri.cpp index b58422165..aca7875a5 100644 --- a/src/magnet_uri.cpp +++ b/src/magnet_uri.cpp @@ -109,18 +109,19 @@ namespace libtorrent { namespace { torrent_handle add_magnet_uri_deprecated(session& ses, std::string const& uri - , add_torrent_params p, error_code& ec) + , add_torrent_params const& p, error_code& ec) { - parse_magnet_uri(uri, p, ec); + add_torrent_params params(p); + parse_magnet_uri(uri, params, ec); if (ec) return torrent_handle(); - return ses.add_torrent(std::move(p), ec); + return ses.add_torrent(std::move(params), ec); } } torrent_handle add_magnet_uri(session& ses, std::string const& uri - , add_torrent_params p, error_code& ec) + , add_torrent_params const& p, error_code& ec) { - return add_magnet_uri_deprecated(ses, uri, std::move(p), ec); + return add_magnet_uri_deprecated(ses, uri, p, ec); } #ifndef BOOST_NO_EXCEPTIONS @@ -145,10 +146,10 @@ namespace libtorrent { } torrent_handle add_magnet_uri(session& ses, std::string const& uri - , add_torrent_params p) + , add_torrent_params const& p) { error_code ec; - torrent_handle ret = add_magnet_uri_deprecated(ses, uri, std::move(p), ec); + torrent_handle ret = add_magnet_uri_deprecated(ses, uri, p, ec); if (ec) aux::throw_ex(ec); return ret; }