Ignore:
Timestamp:
Oct 24, 2010, 1:08:08 AM (11 years ago)
Author:
charles
Message:

(trunk libT) #3662 "libtransmission cpu optimization: fewer calls to tr_time_msec()" -- fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r11299 r11349  
    9999        const unsigned int payload = MIN( next->length, bytes_transferred );
    100100        const unsigned int overhead = guessPacketOverhead( payload );
    101 
    102         tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData );
     101        const uint64_t now = tr_time_msec( );
     102
     103        tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData, now );
    103104
    104105        if( overhead > 0 )
    105             tr_bandwidthUsed( &io->bandwidth, TR_UP, overhead, FALSE );
     106            tr_bandwidthUsed( &io->bandwidth, TR_UP, overhead, FALSE, now );
    106107
    107108        if( io->didWrite )
     
    150151            assert( tr_isPeerIo( io ) );
    151152
    152             if( piece )
    153                 tr_bandwidthUsed( &io->bandwidth, TR_DOWN, piece, TRUE );
    154 
    155             if( used != piece )
    156                 tr_bandwidthUsed( &io->bandwidth, TR_DOWN, used - piece, FALSE );
     153            if( piece || (piece!=used) )
     154            {
     155                const uint64_t now = tr_time_msec( );
     156
     157                if( piece )
     158                    tr_bandwidthUsed( &io->bandwidth, TR_DOWN, piece, TRUE, now );
     159
     160                if( used != piece )
     161                    tr_bandwidthUsed( &io->bandwidth, TR_DOWN, used - piece, FALSE, now );
     162            }
    157163
    158164            switch( ret )
Note: See TracChangeset for help on using the changeset viewer.