minor general code cleanup and refactor

This commit is contained in:
Alden Torres 2017-03-27 14:40:19 -04:00 committed by Arvid Norberg
parent ff038fb548
commit f80e95705a
10 changed files with 11 additions and 25 deletions

View File

@ -51,8 +51,8 @@ namespace libtorrent
explicit announce_entry(string_view u); explicit announce_entry(string_view u);
announce_entry(); announce_entry();
~announce_entry(); ~announce_entry();
announce_entry(announce_entry const&) = default; announce_entry(announce_entry const&);
announce_entry& operator=(announce_entry const&) = default; announce_entry& operator=(announce_entry const&);
// tracker URL as it appeared in the torrent file // tracker URL as it appeared in the torrent file
std::string url; std::string url;

View File

@ -62,4 +62,3 @@ namespace aux {
}} }}
#endif #endif

View File

@ -63,6 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <map> #include <map>
#include <list> #include <list>
#include <string> #include <string>
#include <vector>
#include <stdexcept> #include <stdexcept>
#include <cstdint> #include <cstdint>
#if TORRENT_USE_IOSTREAM #if TORRENT_USE_IOSTREAM

View File

@ -34,13 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_RESOLVER_HPP_INCLUDE #define TORRENT_RESOLVER_HPP_INCLUDE
#include "libtorrent/aux_/disable_warnings_push.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <unordered_map> #include <unordered_map>
#include <functional>
#include <vector> #include <vector>
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
@ -73,8 +70,7 @@ private:
std::vector<address> addresses; std::vector<address> addresses;
}; };
using cache_t = std::unordered_map<std::string, dns_cache_entry>; std::unordered_map<std::string, dns_cache_entry> m_cache;
cache_t m_cache;
io_service& m_ios; io_service& m_ios;
// all lookups in this resolver are aborted on shutdown. // all lookups in this resolver are aborted on shutdown.

View File

@ -44,13 +44,12 @@ namespace libtorrent
struct TORRENT_EXTRA_EXPORT resolver_interface struct TORRENT_EXTRA_EXPORT resolver_interface
{ {
typedef std::function<void(error_code const&, std::vector<address> const&)> using callback_t = std::function<void(error_code const&, std::vector<address> const&)>;
callback_t;
enum flags_t enum flags_t
{ {
// this flag will make async_resolve() always use the cache if we have an // 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 // lookup quickly is more important than accuracy
prefer_cache = 1, prefer_cache = 1,
@ -70,4 +69,3 @@ protected:
} }
#endif #endif

View File

@ -33,9 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_SPAN_HPP_INCLUDED #ifndef TORRENT_SPAN_HPP_INCLUDED
#define TORRENT_SPAN_HPP_INCLUDED #define TORRENT_SPAN_HPP_INCLUDED
#include <vector>
#include <array> #include <array>
#include <type_traits> // for std::is_convertible #include <type_traits>
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
namespace libtorrent namespace libtorrent

View File

@ -68,6 +68,8 @@ namespace libtorrent
{} {}
announce_entry::~announce_entry() = default; 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 #ifndef TORRENT_NO_DEPRECATE
int announce_entry::next_announce_in() const int announce_entry::next_announce_in() const

View File

@ -34,8 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/debug.hpp" #include "libtorrent/debug.hpp"
#include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/time.hpp"
#include <functional>
namespace libtorrent namespace libtorrent
{ {
resolver::resolver(io_service& ios) resolver::resolver(io_service& ios)
@ -73,9 +71,8 @@ namespace libtorrent
// oldest entries // oldest entries
if (int(m_cache.size()) > m_max_size) if (int(m_cache.size()) > m_max_size)
{ {
cache_t::iterator oldest = m_cache.begin(); auto oldest = m_cache.begin();
for (cache_t::iterator k = m_cache.begin(); for (auto k = m_cache.begin(); k != m_cache.end(); ++k)
k != m_cache.end(); ++k)
{ {
if (k->second.last_seen < oldest->second.last_seen) if (k->second.last_seen < oldest->second.last_seen)
oldest = k; oldest = k;

View File

@ -35,12 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/file.hpp" #include "libtorrent/file.hpp"
#include <string>
namespace libtorrent namespace libtorrent
{ {
class file_storage;
stat_cache::stat_cache() {} stat_cache::stat_cache() {}
stat_cache::~stat_cache() = default; stat_cache::~stat_cache() = default;

View File

@ -63,6 +63,4 @@ namespace libtorrent { namespace aux
#endif #endif
} }
}} }}