minor and general code cleanup/refactor

This commit is contained in:
Alden Torres 2017-10-24 16:27:17 -04:00 committed by Arvid Norberg
parent 174a2ca65f
commit b380bf8059
5 changed files with 18 additions and 21 deletions

View File

@ -308,7 +308,6 @@ private:
#if TORRENT_USE_ASSERTS
int magic = 1337;
#endif
void close() const;
bool operator<(rootdevice const& rhs) const
{ return url < rhs.url; }

View File

@ -1852,7 +1852,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
// if we encounter any read jobs in the queue, we need to clear the
// "outstanding_read" flag on its piece, as we abort the job
std::vector<std::pair<storage_interface*, piece_index_t> > pieces;
std::vector<std::pair<storage_interface*, piece_index_t>> pieces;
storage_interface* to_delete = m_torrents[storage].get();

View File

@ -122,8 +122,8 @@ namespace libtorrent {
file_storage const& fs = files();
for (file_index_t i(0); i < prio.end_index(); ++i)
{
int const old_prio = m_file_priority[i];
int new_prio = prio[i];
std::uint8_t const old_prio = m_file_priority[i];
std::uint8_t new_prio = prio[i];
if (old_prio == 0 && new_prio != 0)
{
// move stuff out of the part file
@ -183,7 +183,7 @@ namespace libtorrent {
*/
}
ec.ec.clear();
m_file_priority[i] = std::uint8_t(new_prio);
m_file_priority[i] = new_prio;
if (m_file_priority[i] == 0 && !fs.pad_file_at(i))
need_partfile();

View File

@ -93,14 +93,6 @@ upnp::rootdevice& upnp::rootdevice::operator=(rootdevice const&) = default;
upnp::rootdevice::rootdevice(rootdevice&&) = default;
upnp::rootdevice& upnp::rootdevice::operator=(rootdevice&&) = default;
void upnp::rootdevice::close() const
{
TORRENT_ASSERT(magic == 1337);
if (!upnp_connection) return;
upnp_connection->close();
upnp_connection.reset();
}
// TODO: 3 bind the broadcast socket. it would probably have to be changed to a vector of interfaces to
// bind to, since the broadcast socket opens one socket per local
// interface by default
@ -220,10 +212,13 @@ port_mapping_t upnp::add_mapping(portmap_protocol const p, int const external_po
TORRENT_ASSERT(external_port != 0);
#ifndef TORRENT_DISABLE_LOGGING
log("adding port map: [ protocol: %s ext_port: %u "
"local_ep: %s ] %s", (p == portmap_protocol::tcp?"tcp":"udp")
, external_port
, print_endpoint(local_ep).c_str(), m_disabled ? "DISABLED": "");
if (should_log())
{
log("adding port map: [ protocol: %s ext_port: %u "
"local_ep: %s ] %s", (p == portmap_protocol::tcp?"tcp":"udp")
, external_port
, print_endpoint(local_ep).c_str(), m_disabled ? "DISABLED": "");
}
#endif
if (m_disabled) return port_mapping_t{-1};
@ -279,9 +274,12 @@ void upnp::delete_mapping(port_mapping_t const mapping)
global_mapping_t const& m = m_mappings[mapping];
#ifndef TORRENT_DISABLE_LOGGING
log("deleting port map: [ protocol: %s ext_port: %u "
"local_ep: %s ]", (m.protocol == portmap_protocol::tcp?"tcp":"udp"), m.external_port
, print_endpoint(m.local_ep).c_str());
if (should_log())
{
log("deleting port map: [ protocol: %s ext_port: %u "
"local_ep: %s ]", (m.protocol == portmap_protocol::tcp?"tcp":"udp"), m.external_port
, print_endpoint(m.local_ep).c_str());
}
#endif
if (m.protocol == portmap_protocol::none) return;

View File

@ -116,7 +116,7 @@ TORRENT_TEST(span_of_spans)
{
std::vector<char> v1 = {1,2,3,4};
span<char> s1(v1);
span<span<char> > a(s1);
span<span<char>> a(s1);
TEST_CHECK(a == g(s1));
TEST_CHECK(a.size() == 1);
TEST_CHECK(a[0].size() == 4);