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

This commit is contained in:
arvidn 2018-11-12 01:51:05 +01:00 committed by Arvid Norberg
parent 4d88c83576
commit 437887ca37
2 changed files with 10 additions and 9 deletions

View File

@ -66,13 +66,13 @@ namespace libtorrent {
// deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url
TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED_EXPORT
torrent_handle add_magnet_uri(session& ses, std::string const& uri torrent_handle add_magnet_uri(session& ses, std::string const& uri
, add_torrent_params p); , add_torrent_params const& p);
#endif #endif
// deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url // deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url
TORRENT_DEPRECATED_EXPORT TORRENT_DEPRECATED_EXPORT
torrent_handle add_magnet_uri(session& ses, std::string const& uri 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 #endif // TORRENT_ABI_VERSION

View File

@ -109,18 +109,19 @@ namespace libtorrent {
namespace { namespace {
torrent_handle add_magnet_uri_deprecated(session& ses, std::string const& uri 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(); 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 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 #ifndef BOOST_NO_EXCEPTIONS
@ -145,10 +146,10 @@ namespace libtorrent {
} }
torrent_handle add_magnet_uri(session& ses, std::string const& uri torrent_handle add_magnet_uri(session& ses, std::string const& uri
, add_torrent_params p) , add_torrent_params const& p)
{ {
error_code ec; 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<system_error>(ec); if (ec) aux::throw_ex<system_error>(ec);
return ret; return ret;
} }