From 10deff2f914056355791c249f27bc31107f240c9 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 30 Jun 2018 18:43:17 +0200 Subject: [PATCH] fix some unintentional copies (with explicit moves) --- src/alert.cpp | 6 +++--- src/kademlia/find_data.cpp | 2 +- src/kademlia/get_item.cpp | 2 +- src/kademlia/get_peers.cpp | 6 +++--- src/kademlia/refresh.cpp | 2 +- src/kademlia/traversal_algorithm.cpp | 2 +- src/session_stats.cpp | 2 +- src/torrent_handle.cpp | 4 ++-- src/ut_pex.cpp | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index 1dd9233ec..06a1d3a22 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -2173,7 +2173,7 @@ namespace { peers.push_back(detail::read_v6_endpoint(v6_ptr)); #endif - return peers; + return std::move(peers); } dht_direct_response_alert::dht_direct_response_alert( @@ -2409,7 +2409,7 @@ namespace { TORRENT_UNUSED(v6_nodes_idx); #endif - return nodes; + return std::move(nodes); } } @@ -2507,7 +2507,7 @@ namespace { const char *ptr = m_alloc.get().ptr(m_samples_idx); std::memcpy(samples.data(), ptr, samples.size() * 20); - return samples; + return std::move(samples); } int dht_sample_infohashes_alert::num_nodes() const diff --git a/src/kademlia/find_data.cpp b/src/kademlia/find_data.cpp index 4c4b0fcc8..4285cb4ea 100644 --- a/src/kademlia/find_data.cpp +++ b/src/kademlia/find_data.cpp @@ -127,7 +127,7 @@ observer_ptr find_data::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } char const* find_data::name() const { return "find_data"; } diff --git a/src/kademlia/get_item.cpp b/src/kademlia/get_item.cpp index 7a1154c0f..7c641f268 100644 --- a/src/kademlia/get_item.cpp +++ b/src/kademlia/get_item.cpp @@ -127,7 +127,7 @@ observer_ptr get_item::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } bool get_item::invoke(observer_ptr o) diff --git a/src/kademlia/get_peers.cpp b/src/kademlia/get_peers.cpp index 9bdcc51f0..abfb2b54e 100644 --- a/src/kademlia/get_peers.cpp +++ b/src/kademlia/get_peers.cpp @@ -157,7 +157,7 @@ observer_ptr get_peers::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } obfuscated_get_peers::obfuscated_get_peers( @@ -184,7 +184,7 @@ observer_ptr obfuscated_get_peers::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } else { @@ -193,7 +193,7 @@ observer_ptr obfuscated_get_peers::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } } diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index efc225160..47f4f4cb3 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -44,7 +44,7 @@ observer_ptr bootstrap::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } bool bootstrap::invoke(observer_ptr o) diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index d1578658a..85fe23c3e 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -77,7 +77,7 @@ observer_ptr traversal_algorithm::new_observer(udp::endpoint const& ep #if TORRENT_USE_ASSERTS if (o) o->m_in_constructor = false; #endif - return o; + return std::move(o); } traversal_algorithm::traversal_algorithm(node& dht_node, node_id const& target) diff --git a/src/session_stats.cpp b/src/session_stats.cpp index 054f20641..42b582272 100644 --- a/src/session_stats.cpp +++ b/src/session_stats.cpp @@ -568,7 +568,7 @@ namespace { stats[i].type = metrics[i].value_index >= counters::num_stats_counters ? stats_metric::type_gauge : stats_metric::type_counter; } - return stats; + return std::move(stats); } int find_metric_idx(string_view name) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 60c58ba43..9fe65e3b7 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -474,7 +474,7 @@ namespace libtorrent { aux::vector ret; auto retp = &ret; sync_call(&torrent::piece_priorities, retp); - return ret; + return std::move(ret); } #if TORRENT_ABI_VERSION == 1 @@ -529,7 +529,7 @@ namespace libtorrent { aux::vector ret; auto retp = &ret; sync_call(&torrent::file_priorities, retp); - return ret; + return std::move(ret); } #if TORRENT_ABI_VERSION == 1 diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index b3ba0e7d4..28bd6ea6e 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -636,7 +636,7 @@ namespace libtorrent {namespace { bt_peer_connection* c = static_cast(pc.native_handle().get()); auto p = std::make_shared(m_torrent, *c, *this); c->set_ut_pex(p); - return p; + return std::move(p); } } }