From 885e4f8fc4a3a2e1257b1bda183fa87d6312e072 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 22 Sep 2016 12:00:31 -0700 Subject: [PATCH] use default member initializers instead of initialization lists in announce_entry (#1129) --- include/libtorrent/announce_entry.hpp | 14 +++++++------- src/announce_entry.cpp | 23 ++++------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/libtorrent/announce_entry.hpp b/include/libtorrent/announce_entry.hpp index 8ac5a91d4..03fe75e51 100644 --- a/include/libtorrent/announce_entry.hpp +++ b/include/libtorrent/announce_entry.hpp @@ -79,10 +79,10 @@ namespace libtorrent int min_announce_in() const; // the time of next tracker announce - time_point next_announce; + time_point next_announce = min_time(); // no announces before this time - time_point min_announce; + time_point min_announce = min_time(); // TODO: include the number of peers received from this tracker, at last // announce @@ -97,16 +97,16 @@ namespace libtorrent // if this tracker has returned scrape data, these fields are filled in // with valid numbers. Otherwise they are set to -1. the number of // current downloaders - int scrape_incomplete; - int scrape_complete; - int scrape_downloaded; + int scrape_incomplete = -1; + int scrape_complete = -1; + int scrape_downloaded = -1; // the tier this tracker belongs to - std::uint8_t tier; + std::uint8_t tier = 0; // the max number of failures to announce to this tracker in // a row, before this tracker is not used anymore. 0 means unlimited - std::uint8_t fail_limit; + std::uint8_t fail_limit = 0; // the number of times in a row we have failed to announce to this // tracker. diff --git a/src/announce_entry.cpp b/src/announce_entry.cpp index fe75d5c62..56ae2395c 100644 --- a/src/announce_entry.cpp +++ b/src/announce_entry.cpp @@ -49,13 +49,6 @@ namespace libtorrent announce_entry::announce_entry(std::string const& u) : url(u) - , next_announce(min_time()) - , min_announce(min_time()) - , scrape_incomplete(-1) - , scrape_complete(-1) - , scrape_downloaded(-1) - , tier(0) - , fail_limit(0) , fails(0) , updating(false) , source(0) @@ -66,14 +59,7 @@ namespace libtorrent {} announce_entry::announce_entry() - : next_announce(min_time()) - , min_announce(min_time()) - , scrape_incomplete(-1) - , scrape_complete(-1) - , scrape_downloaded(-1) - , tier(0) - , fail_limit(0) - , fails(0) + : fails(0) , updating(false) , source(0) , verified(false) @@ -104,10 +90,9 @@ namespace libtorrent // 7, 15, 27, 45, 95, 127, 165, ... seconds // with the default tracker_backoff of 250 int const tracker_backoff_seconds = total_seconds(tracker_backoff); - int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails) + int const delay = std::max(std::min(tracker_retry_delay_min + int(fails) * int(fails) * tracker_retry_delay_min * tracker_backoff_seconds / 100 - , int(tracker_retry_delay_max)); - delay = (std::max)(delay, retry_interval); + , int(tracker_retry_delay_max)), retry_interval); next_announce = aux::time_now() + seconds(delay); updating = false; } @@ -116,7 +101,7 @@ namespace libtorrent { // if we're a seed and we haven't sent a completed // event, we need to let this announce through - bool need_send_complete = is_seed && !complete_sent; + bool const need_send_complete = is_seed && !complete_sent; return now >= next_announce && (now >= min_announce || need_send_complete)