minor refactor to make it more swig friendly (#1014)

This commit is contained in:
Alden Torres 2016-08-20 11:29:31 -04:00 committed by Arvid Norberg
parent 8f7901dd25
commit bd557ca2b2
4 changed files with 9 additions and 17 deletions

View File

@ -83,7 +83,7 @@ namespace libtorrent
static sha1_hash min()
{
sha1_hash ret;
std::memset(ret.m_number, 0, size());
// all bits are already 0
return ret;
}
@ -92,7 +92,7 @@ namespace libtorrent
// are ignored, ``s`` is treated like a raw memory buffer.
explicit sha1_hash(char const* s)
{
if (s == 0) clear();
if (s == nullptr) clear();
else std::memcpy(m_number, s, size());
}
#ifndef TORRENT_NO_DEPRECATE

View File

@ -475,12 +475,9 @@ namespace libtorrent
const std::string& comment() const
{ return m_comment; }
// dht nodes to add to the routing table/bootstrap from
using nodes_t = std::vector<std::pair<std::string, int>>;
// If this torrent contains any DHT nodes, they are put in this vector in
// their original form (host name and port number).
nodes_t const& nodes() const
std::vector<std::pair<std::string, int>> const& nodes() const
{ return m_nodes; }
// This is used when creating torrent. Use this to add a known DHT node.
@ -551,7 +548,8 @@ namespace libtorrent
// the urls to the trackers
std::vector<announce_entry> m_urls;
std::vector<web_seed_entry> m_web_seeds;
nodes_t m_nodes;
// dht nodes to add to the routing table/bootstrap from
std::vector<std::pair<std::string, int>> m_nodes;
// the info-hashes (20 bytes each) in the "similar" key. The pointers
// point directly into the info_section. When copied, these pointers must

View File

@ -395,10 +395,8 @@ namespace libtorrent
if (!ti.creator().empty()) set_creator(ti.creator().c_str());
if (!ti.comment().empty()) set_comment(ti.comment().c_str());
torrent_info::nodes_t const& nodes = ti.nodes();
for (torrent_info::nodes_t::const_iterator i = nodes.begin()
, end(nodes.end()); i != end; ++i)
add_node(*i);
for (auto const& n : ti.nodes())
add_node(n);
std::vector<libtorrent::announce_entry> const& trackers = ti.trackers();
for (std::vector<libtorrent::announce_entry>::const_iterator i = trackers.begin()

View File

@ -4655,12 +4655,8 @@ namespace aux {
#ifndef TORRENT_DISABLE_DHT
if (params.ti)
{
torrent_info::nodes_t const& nodes = params.ti->nodes();
for (std::vector<std::pair<std::string, int> >::const_iterator i = nodes.begin()
, end(nodes.end()); i != end; ++i)
{
add_dht_node_name(*i);
}
for (auto const& n : params.ti->nodes())
add_dht_node_name(n);
}
#endif