Changeset 6102


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

(libT) make tr_torrentAmountFinished() much faster when the torrent is complete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r6092 r6102  
    305305tr_cpGetAmountDone( const tr_completion * cp, float * tab, int tabCount )
    306306{
     307    int i;
     308    const int isComplete = tr_cpGetStatus ( cp ) == TR_CP_COMPLETE;
    307309    const int tabSpan = cp->tor->blockCount / tabCount;
    308310    tr_block_index_t block_i = 0;
    309     int tab_i;
    310     for( tab_i=0; tab_i<tabCount; ++tab_i ) {
    311         int loop, have;
    312         for( loop=have=0; loop<tabSpan; ++loop )
    313             if( tr_cpBlockIsComplete( cp, block_i++ ) )
    314                 ++have;
    315         tab[tab_i] = (float)have / tabSpan;
     311    for( i=0; i<tabCount; ++i ) {
     312        if( isComplete )
     313            tab[i] = 1.0f;
     314        else {
     315            int loop, have;
     316            for( loop=have=0; loop<tabSpan; ++loop )
     317                if( tr_cpBlockIsComplete( cp, block_i++ ) )
     318                    ++have;
     319            tab[i] = (float)have / tabSpan;
     320        }
    316321    }
    317322}
Note: See TracChangeset for help on using the changeset viewer.