Changeset 6103


Ignore:
Timestamp:
Jun 9, 2008, 11:11:15 PM (14 years ago)
Author:
charles
Message:

(libT) make tr_torrentAvailability() a lot faster in the case where the torrent is complete, and a little faster in the genral case too.

File:
1 edited

Legend:

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

    r6101 r6103  
    12871287    const tr_torrent * tor;
    12881288    float interval;
     1289    int isComplete;
     1290    int peerCount;
     1291    const tr_peer ** peers;
    12891292
    12901293    managerLock( (tr_peerMgr*)manager );
     
    12931296    tor = t->tor;
    12941297    interval = tor->info.pieceCount / (float)tabCount;
     1298    isComplete = tor && ( tr_cpGetStatus ( tor->completion ) == TR_CP_COMPLETE );
     1299    peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
    12951300
    12961301    memset( tab, 0, tabCount );
     
    13021307        if( tor == NULL )
    13031308            tab[i] = 0;
    1304         else if( tr_cpPieceIsComplete( tor->completion, piece ) )
     1309        else if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
    13051310            tab[i] = -1;
    1306         else {
    1307             int j, peerCount;
    1308             const tr_peer ** peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
     1311        else if( peerCount ) {
     1312            int j;
    13091313            for( j=0; j<peerCount; ++j )
    13101314                if( tr_bitfieldHas( peers[j]->have, i ) )
Note: See TracChangeset for help on using the changeset viewer.