Changeset 8212


Ignore:
Timestamp:
Apr 11, 2009, 3:24:36 AM (13 years ago)
Author:
charles
Message:

(trunk libT) omit some unnecessary tests on the bitfield checks. these seem small, but bitfields are always the top CPU abuser when I profile...

Location:
trunk/libtransmission
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r7797 r8212  
    8383                /* we have part of the piece... */
    8484                const tr_block_index_t b = tr_torPieceFirstBlock( tor, i );
    85                 const tr_block_index_t e = b + tr_torPieceCountBlocks( tor,
    86                                                                        i );
    87                 tr_block_index_t       j;
     85                const tr_block_index_t e = b + tr_torPieceCountBlocks( tor, i );
     86                tr_block_index_t j;
    8887                for( j = b; j < e; ++j )
    89                     if( tr_cpBlockIsComplete( cp, j ) )
     88                    if( tr_cpBlockIsCompleteFast( cp, j ) )
    9089                        size += tr_torBlockCountBytes( tor, j );
    9190            }
     
    130129
    131130    for( block = start; block < end; ++block )
    132         if( tr_cpBlockIsComplete( cp, block ) )
     131        if( tr_cpBlockIsCompleteFast( cp, block ) )
    133132            cp->sizeNow -= tr_torBlockCountBytes( tor, block );
    134133
     
    344343
    345344    for( block=firstBlock; block<=lastBlock; ++block )
    346         if( !tr_cpBlockIsComplete( cp, block ) )
     345        if( !tr_cpBlockIsCompleteFast( cp, block ) )
    347346            return FALSE;
    348347
  • trunk/libtransmission/completion.h

    r8060 r8212  
    136136**/
    137137
    138 static TR_INLINE tr_bool tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) {
     138static TR_INLINE tr_bool tr_cpBlockIsCompleteFast( const tr_completion * cp, tr_block_index_t block )
     139{
     140    return tr_bitfieldHasFast( &cp->blockBitfield, block );
     141}
     142
     143static TR_INLINE tr_bool tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block )
     144{
    139145    return tr_bitfieldHas( &cp->blockBitfield, block );
    140146}
  • trunk/libtransmission/peer-mgr.c

    r8186 r8212  
    694694        i->blockIndex = 0;
    695695        for( block=b; block!=e; ++block )
    696             if( !tr_cpBlockIsComplete( &tor->completion, block ) )
     696            if( !tr_cpBlockIsCompleteFast( &tor->completion, block ) )
    697697                i->blocks[i->blockCount++] = block;
    698698    }
  • trunk/libtransmission/torrent.c

    r8186 r8212  
    908908        s->desiredAvailable = 0;
    909909        for( i = 0; i < tor->info.pieceCount; ++i )
    910             if( !tor->info.pieces[i].dnd && tr_bitfieldHas( peerPieces, i ) )
     910            if( !tor->info.pieces[i].dnd && tr_bitfieldHasFast( peerPieces, i ) )
    911911                s->desiredAvailable += tr_cpMissingBlocksInPiece( &tor->completion, i );
    912912        s->desiredAvailable *= tor->blockSize;
     
    993993    if( firstBlock == lastBlock )
    994994    {
    995         if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) )
     995        if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
    996996            haveBytes += lastBlockOffset + 1 - firstBlockOffset;
    997997    }
     
    10001000        tr_block_index_t i;
    10011001
    1002         if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) )
     1002        if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
    10031003            haveBytes += tor->blockSize - firstBlockOffset;
    10041004
    10051005        for( i = firstBlock + 1; i < lastBlock; ++i )
    1006             if( tr_cpBlockIsComplete( &tor->completion, i ) )
     1006            if( tr_cpBlockIsCompleteFast( &tor->completion, i ) )
    10071007                haveBytes += tor->blockSize;
    10081008
    1009         if( tr_cpBlockIsComplete( &tor->completion, lastBlock ) )
     1009        if( tr_cpBlockIsCompleteFast( &tor->completion, lastBlock ) )
    10101010            haveBytes += lastBlockOffset + 1;
    10111011    }
  • trunk/libtransmission/torrent.h

    r8186 r8212  
    293293static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent  * tor, tr_piece_index_t i )
    294294{
    295     return tr_bitfieldHas( &tor->checkedPieces, i );
     295    return tr_bitfieldHasFast( &tor->checkedPieces, i );
    296296}
    297297
Note: See TracChangeset for help on using the changeset viewer.