mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk libT) omit some unnecessary tests on the bitfield checks. these seem small, but bitfields are always the top CPU abuser when I profile...
This commit is contained in:
parent
afe11e1386
commit
f4dde1eb67
5 changed files with 19 additions and 14 deletions
|
@ -82,11 +82,10 @@ tr_cpSizeWhenDone( const tr_completion * ccp )
|
|||
{
|
||||
/* we have part of the piece... */
|
||||
const tr_block_index_t b = tr_torPieceFirstBlock( tor, i );
|
||||
const tr_block_index_t e = b + tr_torPieceCountBlocks( tor,
|
||||
i );
|
||||
const tr_block_index_t e = b + tr_torPieceCountBlocks( tor, i );
|
||||
tr_block_index_t j;
|
||||
for( j = b; j < e; ++j )
|
||||
if( tr_cpBlockIsComplete( cp, j ) )
|
||||
if( tr_cpBlockIsCompleteFast( cp, j ) )
|
||||
size += tr_torBlockCountBytes( tor, j );
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +128,7 @@ tr_cpPieceRem( tr_completion * cp,
|
|||
assert( end <= tor->blockCount );
|
||||
|
||||
for( block = start; block < end; ++block )
|
||||
if( tr_cpBlockIsComplete( cp, block ) )
|
||||
if( tr_cpBlockIsCompleteFast( cp, block ) )
|
||||
cp->sizeNow -= tr_torBlockCountBytes( tor, block );
|
||||
|
||||
cp->sizeWhenDoneIsDirty = 1;
|
||||
|
@ -343,7 +342,7 @@ tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t fileIndex )
|
|||
firstBlock, lastBlock );
|
||||
|
||||
for( block=firstBlock; block<=lastBlock; ++block )
|
||||
if( !tr_cpBlockIsComplete( cp, block ) )
|
||||
if( !tr_cpBlockIsCompleteFast( cp, block ) )
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -135,7 +135,13 @@ tr_bool tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t );
|
|||
*** Blocks
|
||||
**/
|
||||
|
||||
static TR_INLINE tr_bool tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) {
|
||||
static TR_INLINE tr_bool tr_cpBlockIsCompleteFast( const tr_completion * cp, tr_block_index_t block )
|
||||
{
|
||||
return tr_bitfieldHasFast( &cp->blockBitfield, block );
|
||||
}
|
||||
|
||||
static TR_INLINE tr_bool tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block )
|
||||
{
|
||||
return tr_bitfieldHas( &cp->blockBitfield, block );
|
||||
}
|
||||
|
||||
|
|
|
@ -693,7 +693,7 @@ blockIteratorNext( struct tr_blockIterator * i, tr_block_index_t * setme )
|
|||
i->blockCount = 0;
|
||||
i->blockIndex = 0;
|
||||
for( block=b; block!=e; ++block )
|
||||
if( !tr_cpBlockIsComplete( &tor->completion, block ) )
|
||||
if( !tr_cpBlockIsCompleteFast( &tor->completion, block ) )
|
||||
i->blocks[i->blockCount++] = block;
|
||||
}
|
||||
|
||||
|
|
|
@ -907,7 +907,7 @@ tr_torrentStat( tr_torrent * tor )
|
|||
tr_bitfield * peerPieces = tr_peerMgrGetAvailable( tor );
|
||||
s->desiredAvailable = 0;
|
||||
for( i = 0; i < tor->info.pieceCount; ++i )
|
||||
if( !tor->info.pieces[i].dnd && tr_bitfieldHas( peerPieces, i ) )
|
||||
if( !tor->info.pieces[i].dnd && tr_bitfieldHasFast( peerPieces, i ) )
|
||||
s->desiredAvailable += tr_cpMissingBlocksInPiece( &tor->completion, i );
|
||||
s->desiredAvailable *= tor->blockSize;
|
||||
tr_bitfieldFree( peerPieces );
|
||||
|
@ -992,21 +992,21 @@ fileBytesCompleted( const tr_torrent * tor,
|
|||
|
||||
if( firstBlock == lastBlock )
|
||||
{
|
||||
if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) )
|
||||
if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
|
||||
haveBytes += lastBlockOffset + 1 - firstBlockOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_block_index_t i;
|
||||
|
||||
if( tr_cpBlockIsComplete( &tor->completion, firstBlock ) )
|
||||
if( tr_cpBlockIsCompleteFast( &tor->completion, firstBlock ) )
|
||||
haveBytes += tor->blockSize - firstBlockOffset;
|
||||
|
||||
for( i = firstBlock + 1; i < lastBlock; ++i )
|
||||
if( tr_cpBlockIsComplete( &tor->completion, i ) )
|
||||
if( tr_cpBlockIsCompleteFast( &tor->completion, i ) )
|
||||
haveBytes += tor->blockSize;
|
||||
|
||||
if( tr_cpBlockIsComplete( &tor->completion, lastBlock ) )
|
||||
if( tr_cpBlockIsCompleteFast( &tor->completion, lastBlock ) )
|
||||
haveBytes += lastBlockOffset + 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ static TR_INLINE tr_bool tr_torrentAllowsPex( const tr_torrent * tor )
|
|||
|
||||
static TR_INLINE tr_bool tr_torrentIsPieceChecked( const tr_torrent * tor, tr_piece_index_t i )
|
||||
{
|
||||
return tr_bitfieldHas( &tor->checkedPieces, i );
|
||||
return tr_bitfieldHasFast( &tor->checkedPieces, i );
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
Loading…
Reference in a new issue