forked from premiere/premiere-libtorrent
minor code refactor for more use of const and emplace
This commit is contained in:
parent
058419a77c
commit
28c94b54ed
|
@ -3957,7 +3957,7 @@ namespace libtorrent {
|
||||||
// blocks that are in the same piece into larger requests
|
// blocks that are in the same piece into larger requests
|
||||||
if (m_request_large_blocks)
|
if (m_request_large_blocks)
|
||||||
{
|
{
|
||||||
int blocks_per_piece = t->torrent_file().piece_length() / t->block_size();
|
int const blocks_per_piece = t->torrent_file().piece_length() / t->block_size();
|
||||||
|
|
||||||
while (!m_request_queue.empty())
|
while (!m_request_queue.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -3901,8 +3901,8 @@ namespace aux {
|
||||||
bool operator()(opt_unchoke_candidate const& l
|
bool operator()(opt_unchoke_candidate const& l
|
||||||
, opt_unchoke_candidate const& r) const
|
, opt_unchoke_candidate const& r) const
|
||||||
{
|
{
|
||||||
torrent_peer* pil = (*l.peer)->peer_info_struct();
|
torrent_peer const* pil = (*l.peer)->peer_info_struct();
|
||||||
torrent_peer* pir = (*r.peer)->peer_info_struct();
|
torrent_peer const* pir = (*r.peer)->peer_info_struct();
|
||||||
if (pil->last_optimistically_unchoked
|
if (pil->last_optimistically_unchoked
|
||||||
!= pir->last_optimistically_unchoked)
|
!= pir->last_optimistically_unchoked)
|
||||||
{
|
{
|
||||||
|
@ -3950,7 +3950,7 @@ namespace aux {
|
||||||
prev_opt_unchoke.push_back(pi);
|
prev_opt_unchoke.push_back(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent* t = p->associated_torrent().lock().get();
|
torrent const* t = p->associated_torrent().lock().get();
|
||||||
if (!t) continue;
|
if (!t) continue;
|
||||||
|
|
||||||
// TODO: 3 peers should know whether their torrent is paused or not,
|
// TODO: 3 peers should know whether their torrent is paused or not,
|
||||||
|
@ -4774,17 +4774,15 @@ namespace aux {
|
||||||
add_extensions_to_torrent(torrent_ptr, params.userdata);
|
add_extensions_to_torrent(torrent_ptr, params.userdata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sha1_hash next_lsd(nullptr);
|
sha1_hash const next_lsd = m_next_lsd_torrent != m_torrents.end()
|
||||||
sha1_hash next_dht(nullptr);
|
? m_next_lsd_torrent->first : sha1_hash();
|
||||||
if (m_next_lsd_torrent != m_torrents.end())
|
|
||||||
next_lsd = m_next_lsd_torrent->first;
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
if (m_next_dht_torrent != m_torrents.end())
|
sha1_hash const next_dht = m_next_dht_torrent != m_torrents.end()
|
||||||
next_dht = m_next_dht_torrent->first;
|
? m_next_dht_torrent->first : sha1_hash();
|
||||||
#endif
|
#endif
|
||||||
float const load_factor = m_torrents.load_factor();
|
float const load_factor = m_torrents.load_factor();
|
||||||
|
|
||||||
m_torrents.insert(std::make_pair(params.info_hash, torrent_ptr));
|
m_torrents.emplace(params.info_hash, torrent_ptr);
|
||||||
|
|
||||||
#if !defined TORRENT_DISABLE_ENCRYPTION
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
static char const req2[4] = {'r', 'e', 'q', '2'};
|
static char const req2[4] = {'r', 'e', 'q', '2'};
|
||||||
|
@ -4792,7 +4790,7 @@ namespace aux {
|
||||||
h.update(params.info_hash);
|
h.update(params.info_hash);
|
||||||
// this is SHA1("req2" + info-hash), used for
|
// this is SHA1("req2" + info-hash), used for
|
||||||
// encrypted hand shakes
|
// encrypted hand shakes
|
||||||
m_obfuscated_torrents.insert(std::make_pair(h.final(), torrent_ptr));
|
m_obfuscated_torrents.emplace(h.final(), torrent_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// once we successfully add the torrent, we can disarm the abort action
|
// once we successfully add the torrent, we can disarm the abort action
|
||||||
|
@ -4815,8 +4813,8 @@ namespace aux {
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
//deprecated in 1.2
|
//deprecated in 1.2
|
||||||
if (!params.uuid.empty() || !params.url.empty())
|
if (!params.uuid.empty() || !params.url.empty())
|
||||||
m_uuids.insert(std::make_pair(params.uuid.empty()
|
m_uuids.emplace(params.uuid.empty()
|
||||||
? params.url : params.uuid, torrent_ptr));
|
? params.url : params.uuid, torrent_ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// recalculate auto-managed torrents sooner (or put it off)
|
// recalculate auto-managed torrents sooner (or put it off)
|
||||||
|
@ -5018,7 +5016,7 @@ namespace aux {
|
||||||
|
|
||||||
if (is_utp(s))
|
if (is_utp(s))
|
||||||
{
|
{
|
||||||
auto ep = m_outgoing_sockets.bind(s, remote_address, ec);
|
auto const ep = m_outgoing_sockets.bind(s, remote_address, ec);
|
||||||
if (ep.port() != 0 || ec)
|
if (ep.port() != 0 || ec)
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
|
@ -5090,7 +5088,7 @@ namespace aux {
|
||||||
|
|
||||||
// we didn't find the address as an IP in the interface list. Now,
|
// we didn't find the address as an IP in the interface list. Now,
|
||||||
// resolve which device (if any) has this IP address.
|
// resolve which device (if any) has this IP address.
|
||||||
std::string device = device_for_address(addr, m_io_service, ec);
|
std::string const device = device_for_address(addr, m_io_service, ec);
|
||||||
if (ec) return false;
|
if (ec) return false;
|
||||||
|
|
||||||
// if no device was found to have this address, we fail
|
// if no device was found to have this address, we fail
|
||||||
|
|
Loading…
Reference in New Issue