mirror of
https://github.com/transmission/transmission
synced 2024-12-23 08:13:27 +00:00
refactor: remove tr_torrentStatCached() (#6066)
This commit is contained in:
parent
5808f72f50
commit
917c00e477
4 changed files with 2 additions and 23 deletions
|
@ -626,7 +626,7 @@ void DetailsDialog::Impl::refreshInfo(std::vector<tr_torrent*> const& torrents)
|
|||
infos.reserve(torrents.size());
|
||||
for (auto* const torrent : torrents)
|
||||
{
|
||||
stats.push_back(tr_torrentStatCached(torrent));
|
||||
stats.push_back(tr_torrentStat(torrent));
|
||||
infos.push_back(tr_torrentView(torrent));
|
||||
}
|
||||
|
||||
|
|
|
@ -1441,14 +1441,7 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
auto const now = tr_time_msec();
|
||||
auto const now_sec = tr_time();
|
||||
|
||||
auto swarm_stats = tr_swarm_stats{};
|
||||
|
||||
tor->lastStatTime = now_sec;
|
||||
|
||||
if (tor->swarm != nullptr)
|
||||
{
|
||||
swarm_stats = tr_swarmGetStats(tor->swarm);
|
||||
}
|
||||
auto const swarm_stats = tor->swarm != nullptr ? tr_swarmGetStats(tor->swarm) : tr_swarm_stats{};
|
||||
|
||||
tr_stat* const s = &tor->stats;
|
||||
s->id = tor->id();
|
||||
|
@ -1600,13 +1593,6 @@ tr_stat const* tr_torrentStat(tr_torrent* tor)
|
|||
return s;
|
||||
}
|
||||
|
||||
tr_stat const* tr_torrentStatCached(tr_torrent* tor)
|
||||
{
|
||||
time_t const now = tr_time();
|
||||
|
||||
return (tr_isTorrent(tor) && now == tor->lastStatTime) ? &tor->stats : tr_torrentStat(tor);
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
tr_file_view tr_torrentFile(tr_torrent const* tor, tr_file_index_t file)
|
||||
|
|
|
@ -875,8 +875,6 @@ public:
|
|||
time_t editDate = 0;
|
||||
time_t startDate = 0;
|
||||
|
||||
time_t lastStatTime = 0;
|
||||
|
||||
time_t seconds_downloading_before_current_start_ = 0;
|
||||
time_t seconds_seeding_before_current_start_ = 0;
|
||||
|
||||
|
|
|
@ -1610,11 +1610,6 @@ struct tr_stat
|
|||
second or so to get a new snapshot of the torrent's status. */
|
||||
tr_stat const* tr_torrentStat(tr_torrent* torrent);
|
||||
|
||||
/** Like `tr_torrentStat()`, but only recalculates the statistics if it's
|
||||
been longer than a second since they were last calculated. This can
|
||||
reduce the CPU load if you're calling `tr_torrentStat()` frequently. */
|
||||
tr_stat const* tr_torrentStatCached(tr_torrent* torrent);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @brief Sanity checker to test that the direction is `TR_UP` or `TR_DOWN` */
|
||||
|
|
Loading…
Reference in a new issue