mirror of
https://github.com/transmission/transmission
synced 2025-02-23 14:40:43 +00:00
if tr_torrentStat() is called again in the same second for a torrent, return the cached value.
This commit is contained in:
parent
b498e720e6
commit
e9ca72237f
2 changed files with 8 additions and 0 deletions
|
@ -162,6 +162,7 @@ struct tr_torrent
|
|||
|
||||
tr_recheck_state recheckState;
|
||||
|
||||
time_t lastStatTime;
|
||||
tr_stat stats[2];
|
||||
|
||||
tr_torrent * next;
|
||||
|
|
|
@ -713,6 +713,13 @@ tr_torrentStat( tr_torrent * tor )
|
|||
{
|
||||
tr_stat * s;
|
||||
struct tr_tracker * tc;
|
||||
const time_t now = time( NULL );
|
||||
|
||||
/* generating these stats is expensive --
|
||||
* update a maximum of once per second */
|
||||
if( tor->lastStatTime == now )
|
||||
return &tor->stats[tor->statCur];
|
||||
tor->lastStatTime = now;
|
||||
|
||||
tr_torrentLock( tor );
|
||||
|
||||
|
|
Loading…
Reference in a new issue