use default member initializers instead of initialization lists in announce_entry (#1129)

This commit is contained in:
Arvid Norberg 2016-09-22 12:00:31 -07:00 committed by GitHub
parent c7ec987a1b
commit 885e4f8fc4
2 changed files with 11 additions and 26 deletions

View File

@ -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.

View File

@ -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)