diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 60101e2d4..13d7cfc14 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -42,11 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/debug.hpp" - -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/buffer.hpp" #include "libtorrent/peer_connection.hpp" #include "libtorrent/socket.hpp" diff --git a/include/libtorrent/http_seed_connection.hpp b/include/libtorrent/http_seed_connection.hpp index 6783971b6..75d815b59 100644 --- a/include/libtorrent/http_seed_connection.hpp +++ b/include/libtorrent/http_seed_connection.hpp @@ -38,10 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/config.hpp" #include "libtorrent/web_connection_base.hpp" #include "libtorrent/piece_block_progress.hpp" diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index ee35e8708..64c2126a7 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -74,10 +74,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/aux_/disable_warnings_push.hpp" - #include -#include - #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index 2f600eda3..b2f9445c4 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -40,12 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/config.hpp" #include "libtorrent/web_connection_base.hpp" #include "libtorrent/disk_buffer_holder.hpp" @@ -153,4 +147,3 @@ namespace libtorrent } #endif // TORRENT_WEB_PEER_CONNECTION_HPP_INCLUDED - diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 1959f7708..9e1423db7 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3321,8 +3321,8 @@ namespace libtorrent TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index); TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index); - TORRENT_ASSERT(int(block.piece_index) < t->torrent_file().num_pieces()); - TORRENT_ASSERT(int(block.block_index) < t->torrent_file().piece_size(block.piece_index)); + TORRENT_ASSERT(block.piece_index < t->torrent_file().num_pieces()); + TORRENT_ASSERT(block.block_index < t->torrent_file().piece_size(block.piece_index)); TORRENT_ASSERT(!t->picker().is_requested(block) || (t->picker().num_peers(block) > 0)); TORRENT_ASSERT(!t->have_piece(block.piece_index)); TORRENT_ASSERT(std::find_if(m_download_queue.begin(), m_download_queue.end() diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index a487d60e9..2d801224d 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -3143,7 +3143,7 @@ get_out: TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index); TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index); TORRENT_ASSERT(block.piece_index < m_piece_map.size()); - TORRENT_ASSERT(int(block.block_index) < blocks_in_piece(block.piece_index)); + TORRENT_ASSERT(block.block_index < blocks_in_piece(block.piece_index)); piece_pos const& p = m_piece_map[block.piece_index]; if (!p.downloading()) return 0; diff --git a/src/torrent.cpp b/src/torrent.cpp index c1ccc9958..36fabb648 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3816,9 +3816,8 @@ namespace libtorrent TORRENT_ASSERT(st.total_done >= st.total_wanted_done); std::map downloading_piece; - for (const_peer_iterator i = begin(); i != end(); ++i) + for (auto const& pc : *this) { - peer_connection* pc = *i; piece_block_progress p = pc->downloading_piece_progress(); if (p.piece_index == piece_block_progress::invalid_index) continue; @@ -3830,8 +3829,7 @@ namespace libtorrent if (m_picker->is_finished(block)) continue; - std::map::iterator dp - = downloading_piece.find(block); + auto dp = downloading_piece.find(block); if (dp != downloading_piece.end()) { if (dp->second < p.bytes_downloaded) @@ -3845,12 +3843,11 @@ namespace libtorrent TORRENT_ASSERT(p.full_block_bytes == to_req(piece_block( p.piece_index, p.block_index)).length); } - for (std::map::iterator i = downloading_piece.begin(); - i != downloading_piece.end(); ++i) + for (auto const& p : downloading_piece) { - int done = (std::min)(block_bytes_wanted(i->first), i->second); + int done = (std::min)(block_bytes_wanted(p.first), p.second); st.total_done += done; - if (m_picker->piece_priority(i->first.piece_index) != 0) + if (m_picker->piece_priority(p.first.piece_index) != 0) st.total_wanted_done += done; } @@ -3861,14 +3858,13 @@ namespace libtorrent if (st.total_done >= m_torrent_file->total_size()) { - // Thist happens when a piece has been downloaded completely + // This happens when a piece has been downloaded completely // but not yet verified against the hash std::fprintf(stderr, "num_have: %d\nunfinished:\n", num_have()); - for (std::vector::const_iterator i = - dl_queue.begin(); i != dl_queue.end(); ++i) + for (auto const& dp : dl_queue) { - std::fprintf(stderr, " %d ", i->index); - piece_picker::block_info* info = m_picker->blocks_for_piece(*i); + std::fprintf(stderr, " %d ", dp.index); + piece_picker::block_info* info = m_picker->blocks_for_piece(dp); for (int j = 0; j < blocks_per_piece; ++j) { char const* state = info[j].state @@ -3880,10 +3876,9 @@ namespace libtorrent fputs("downloading pieces:\n", stderr); - for (std::map::iterator i = downloading_piece.begin(); - i != downloading_piece.end(); ++i) + for (auto const& p : downloading_piece) { - std::fprintf(stderr, " %d:%d %d\n", int(i->first.piece_index), int(i->first.block_index), i->second); + std::fprintf(stderr, " %d:%d %d\n", p.first.piece_index, p.first.block_index, p.second); } } @@ -10679,8 +10674,8 @@ namespace libtorrent if (info[k].state == piece_picker::block_info::state_requested) { block = 0; - torrent_peer* p = static_cast(info[k].peer); - if (p && p->connection) + torrent_peer* p = info[k].peer; + if (p != nullptr && p->connection) { peer_connection* peer = static_cast(p->connection); auto pbp = peer->downloading_piece_progress();