From 7f4c8aaf7566391d706adc25bcff1f411f7cc274 Mon Sep 17 00:00:00 2001 From: Pavel Pimenov Date: Tue, 14 Feb 2017 08:17:02 +0300 Subject: [PATCH] Add const peer_request p -> peer_request const& p (#1705) Add const peer_request p -> peer_request const& p --- include/libtorrent/peer_connection.hpp | 4 ++-- include/libtorrent/torrent.hpp | 4 ++-- src/identify_client.cpp | 6 ++++-- src/peer_connection.cpp | 4 ++-- src/torrent.cpp | 8 ++++---- src/upnp.cpp | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 92429b074..6b814ee29 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -753,9 +753,9 @@ namespace libtorrent void do_update_interest(); void fill_send_buffer(); void on_disk_read_complete(disk_buffer_holder disk_block, int flags - , storage_error const& error, peer_request r, time_point issue_time); + , storage_error const& error, peer_request const& r, time_point issue_time); void on_disk_write_complete(storage_error const& error - , peer_request r, std::shared_ptr t); + , peer_request const &r, std::shared_ptr t); void on_seed_mode_hashed(piece_index_t piece , sha1_hash const& piece_hash, storage_error const& error); int request_timeout() const; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index cd85a59e6..ce5f63a9b 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -383,7 +383,7 @@ namespace libtorrent enum flags_t { overwrite_existing = 1 }; void add_piece(piece_index_t piece, char const* data, int flags = 0); void on_disk_write_complete(storage_error const& error - , peer_request p); + , peer_request const& p); void set_progress_ppm(int p) { m_progress_ppm = std::uint32_t(p); } struct read_piece_struct @@ -395,7 +395,7 @@ namespace libtorrent }; void read_piece(piece_index_t piece); void on_disk_read_complete(disk_buffer_holder block, int flags, storage_error const& se - , peer_request r, std::shared_ptr rp); + , peer_request const& r, std::shared_ptr rp); storage_mode_t storage_mode() const; diff --git a/src/identify_client.cpp b/src/identify_client.cpp index 0e2a1ca8a..cbfa696ae 100644 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -290,7 +290,9 @@ namespace || ((lhs.id[0] == rhs.id[0]) && (lhs.id[1] < rhs.id[1])); } - std::string lookup(fingerprint const& f) +namespace +{ + static std::string lookup(fingerprint const& f) { char identity[200]; @@ -334,7 +336,7 @@ namespace return identity; } - +} bool find_string(char const* id, char const* search) { return std::equal(search, search + std::strlen(search), id); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 6953376d4..5ade351e6 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2947,7 +2947,7 @@ namespace libtorrent } void peer_connection::on_disk_write_complete(storage_error const& error - , peer_request p, std::shared_ptr t) + , peer_request const& p, std::shared_ptr t) { TORRENT_ASSERT(is_single_thread()); #ifndef TORRENT_DISABLE_LOGGING @@ -5199,7 +5199,7 @@ namespace libtorrent void peer_connection::on_disk_read_complete(disk_buffer_holder buffer , int const flags, storage_error const& error - , peer_request r, time_point issue_time) + , peer_request const& r, time_point issue_time) { TORRENT_ASSERT(is_single_thread()); // return value: diff --git a/src/torrent.cpp b/src/torrent.cpp index 2be64a8a8..b3d21c1ce 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1119,7 +1119,7 @@ namespace libtorrent void torrent::on_disk_read_complete(disk_buffer_holder buffer , int, storage_error const& se - , peer_request r, std::shared_ptr rp) try + , peer_request const& r, std::shared_ptr rp) try { // hold a reference until this function returns TORRENT_ASSERT(is_single_thread()); @@ -1261,7 +1261,7 @@ namespace libtorrent , std::bind(&torrent::on_disk_write_complete , shared_from_this(), _1, p)); - piece_block block(piece, i); + piece_block const block(piece, i); bool const was_finished = picker().is_piece_finished(p.piece); bool const multi = picker().num_peers(block) > 1; @@ -1281,7 +1281,7 @@ namespace libtorrent } void torrent::on_disk_write_complete(storage_error const& error - , peer_request p) try + , peer_request const& p) try { TORRENT_ASSERT(is_single_thread()); @@ -1292,7 +1292,7 @@ namespace libtorrent INVARIANT_CHECK; if (m_abort) return; - piece_block block_finished(p.piece, p.start / block_size()); + piece_block const block_finished(p.piece, p.start / block_size()); if (error) { diff --git a/src/upnp.cpp b/src/upnp.cpp index 79c7849e3..e09acbbb2 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -407,7 +407,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer bool non_router = false; if (m_ignore_non_routers) { - std::vector routes = enum_routes(m_io_service, ec); + std::vector const routes = enum_routes(m_io_service, ec); if (std::none_of(routes.begin(), routes.end() , [from] (ip_route const& rt) { return rt.gateway == from.address(); })) {