Changeset 4209


Ignore:
Timestamp:
Dec 19, 2007, 2:44:21 AM (14 years ago)
Author:
charles
Message:

if tr_torrentStat() is called again in the same second for a torrent, return the cached value.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r4004 r4209  
    163163    tr_recheck_state           recheckState;
    164164
     165    time_t                     lastStatTime;
    165166    tr_stat                    stats[2];
    166167
  • trunk/libtransmission/torrent.c

    r4198 r4209  
    714714    tr_stat * s;
    715715    struct tr_tracker * tc;
     716    const time_t now = time( NULL );
     717
     718    /* generating these stats is expensive --
     719     * update a maximum of once per second */
     720    if( tor->lastStatTime == now )
     721        return &tor->stats[tor->statCur];
     722    tor->lastStatTime = now;
    716723
    717724    tr_torrentLock( tor );
Note: See TracChangeset for help on using the changeset viewer.