shrink peers vectors with too much excess capacity

This commit is contained in:
Steven Siloti 2016-09-23 07:30:36 -07:00
parent 89942bf3d4
commit 35cfc6b5d3
1 changed files with 3 additions and 0 deletions

View File

@ -525,6 +525,9 @@ namespace
m_counters.peers -= std::distance(new_end, peers.end());
peers.erase(new_end, peers.end());
// if we're using less than 1/4 of the capacity free up the excess
if (!peers.empty() && peers.capacity() / peers.size() >= 4u)
peers.shrink_to_fit();
}
};
}