attempt to memory optimization in DHT routing table
This commit is contained in:
parent
ceb442bea0
commit
122841fc5e
|
@ -57,7 +57,7 @@ using asio::ip::udp;
|
||||||
|
|
||||||
//TORRENT_DECLARE_LOG(table);
|
//TORRENT_DECLARE_LOG(table);
|
||||||
|
|
||||||
typedef std::deque<node_entry> bucket_t;
|
typedef std::vector<node_entry> bucket_t;
|
||||||
|
|
||||||
// differences in the implementation from the description in
|
// differences in the implementation from the description in
|
||||||
// the paper:
|
// the paper:
|
||||||
|
@ -101,7 +101,7 @@ namespace aux
|
||||||
, bucket_iterator_t end)
|
, bucket_iterator_t end)
|
||||||
: m_bucket_iterator(begin)
|
: m_bucket_iterator(begin)
|
||||||
, m_bucket_end(end)
|
, m_bucket_end(end)
|
||||||
, m_iterator(begin != end ? begin->first.begin() : bucket_t::iterator())
|
, m_iterator(begin != end ? begin->first.begin() : bucket_t::const_iterator())
|
||||||
{
|
{
|
||||||
if (m_bucket_iterator == m_bucket_end) return;
|
if (m_bucket_iterator == m_bucket_end) return;
|
||||||
while (m_iterator == m_bucket_iterator->first.end())
|
while (m_iterator == m_bucket_iterator->first.end())
|
||||||
|
|
|
@ -265,6 +265,7 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
|
||||||
// offline
|
// offline
|
||||||
if ((int)b.size() < m_bucket_size)
|
if ((int)b.size() < m_bucket_size)
|
||||||
{
|
{
|
||||||
|
if (b.empty()) b.reserve(m_bucket_size);
|
||||||
b.push_back(node_entry(id, addr));
|
b.push_back(node_entry(id, addr));
|
||||||
// if bucket index is 0, the node is ourselves
|
// if bucket index is 0, the node is ourselves
|
||||||
// don't updated m_lowest_active_bucket
|
// don't updated m_lowest_active_bucket
|
||||||
|
|
Loading…
Reference in New Issue