From f80e95705a5c36ef124c67987de1fbc95688a4c8 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Mon, 27 Mar 2017 14:40:19 -0400 Subject: [PATCH] minor general code cleanup and refactor --- include/libtorrent/announce_entry.hpp | 4 ++-- include/libtorrent/aux_/storage_piece_set.hpp | 1 - include/libtorrent/entry.hpp | 1 + include/libtorrent/resolver.hpp | 6 +----- include/libtorrent/resolver_interface.hpp | 6 ++---- include/libtorrent/span.hpp | 3 +-- src/announce_entry.cpp | 2 ++ src/resolver.cpp | 7 ++----- src/stat_cache.cpp | 4 ---- src/storage_piece_set.cpp | 2 -- 10 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index 6fb3bbf08..179627388 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -51,8 +51,8 @@ namespace libtorrent explicit announce_entry(string_view u); announce_entry(); ~announce_entry(); - announce_entry(announce_entry const&) = default; - announce_entry& operator=(announce_entry const&) = default; + announce_entry(announce_entry const&); + announce_entry& operator=(announce_entry const&); // tracker URL as it appeared in the torrent file std::string url; diff --git a/include/libtorrent/aux_/storage_piece_set.hpp b/include/libtorrent/aux_/storage_piece_set.hpp index 862aa3d9e..eae99d51c 100644 --- a/include/libtorrent/aux_/storage_piece_set.hpp +++ b/include/libtorrent/aux_/storage_piece_set.hpp @@ -62,4 +62,3 @@ namespace aux { }} #endif - diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 03dd4fd3e..287922662 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -63,6 +63,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #if TORRENT_USE_IOSTREAM diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index d4d53b305..ced6d48b1 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -34,13 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_RESOLVER_HPP_INCLUDE #include "libtorrent/aux_/disable_warnings_push.hpp" - #include - #include "libtorrent/aux_/disable_warnings_pop.hpp" #include -#include #include #include "libtorrent/error_code.hpp" @@ -73,8 +70,7 @@ private: std::vector
addresses; }; - using cache_t = std::unordered_map; - cache_t m_cache; + std::unordered_map m_cache; io_service& m_ios; // all lookups in this resolver are aborted on shutdown. diff --git a/include/libtorrent/resolver_interface.hpp b/include/libtorrent/resolver_interface.hpp index 93c9d0f6c..65f1f26a0 100644 --- a/include/libtorrent/resolver_interface.hpp +++ b/include/libtorrent/resolver_interface.hpp @@ -44,13 +44,12 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT resolver_interface { - typedef std::function const&)> - callback_t; + using callback_t = std::function const&)>; enum flags_t { // this flag will make async_resolve() always use the cache if we have an - // entry, regardless of how old it is. This is usefull when completing the + // entry, regardless of how old it is. This is useful when completing the // lookup quickly is more important than accuracy prefer_cache = 1, @@ -70,4 +69,3 @@ protected: } #endif - diff --git a/include/libtorrent/span.hpp b/include/libtorrent/span.hpp index 54ae174b5..8e5bb375c 100644 --- a/include/libtorrent/span.hpp +++ b/include/libtorrent/span.hpp @@ -33,9 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SPAN_HPP_INCLUDED #define TORRENT_SPAN_HPP_INCLUDED -#include #include -#include // for std::is_convertible +#include #include "libtorrent/assert.hpp" namespace libtorrent diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index 7e18138e6..4b1eab19f 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -68,6 +68,8 @@ namespace libtorrent {} announce_entry::~announce_entry() = default; + announce_entry::announce_entry(announce_entry const&) = default; + announce_entry& announce_entry::operator=(announce_entry const&) = default; #ifndef TORRENT_NO_DEPRECATE int announce_entry::next_announce_in() const diff --git a/src/resolver.cpp b/src/resolver.cpp index 7057edb1d..99de9e3c6 100644 --- a/src/resolver.cpp +++ b/src/resolver.cpp @@ -34,8 +34,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #include "libtorrent/aux_/time.hpp" -#include - namespace libtorrent { resolver::resolver(io_service& ios) @@ -73,9 +71,8 @@ namespace libtorrent // oldest entries if (int(m_cache.size()) > m_max_size) { - cache_t::iterator oldest = m_cache.begin(); - for (cache_t::iterator k = m_cache.begin(); - k != m_cache.end(); ++k) + auto oldest = m_cache.begin(); + for (auto k = m_cache.begin(); k != m_cache.end(); ++k) { if (k->second.last_seen < oldest->second.last_seen) oldest = k; diff --git a/src/stat_cache.cpp b/src/stat_cache.cpp index 93ba94f47..36bbc1e78 100644 --- a/src/stat_cache.cpp +++ b/src/stat_cache.cpp @@ -35,12 +35,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/file.hpp" -#include - namespace libtorrent { - class file_storage; - stat_cache::stat_cache() {} stat_cache::~stat_cache() = default; diff --git a/src/storage_piece_set.cpp b/src/storage_piece_set.cpp index 98f521cb0..489803041 100644 --- a/src/storage_piece_set.cpp +++ b/src/storage_piece_set.cpp @@ -63,6 +63,4 @@ namespace libtorrent { namespace aux #endif } - }} -