diff --git a/libtransmission/completion.c b/libtransmission/completion.c index f6e8ae7bb..f7cd86083 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -179,14 +179,6 @@ tr_cpPieceRem( tr_completion * cp, tr_piece_index_t piece ) tr_bitfieldRem( cp->pieceBitfield, piece ); } -int -tr_cpBlockFindComplete( const tr_completion * cp, - size_t startPos, - size_t * foundPos ) -{ - return tr_bitfieldFindTrue( cp->blockBitfield, startPos, foundPos ); -} - int tr_cpBlockIsComplete( const tr_completion * cp, tr_block_index_t block ) { @@ -236,13 +228,13 @@ tr_cpBlockBitfieldSet( tr_completion * cp, tr_bitfield * bitfield ) assert( bitfield ); assert( cp->blockBitfield ); - if( !cp || !bitfield || ( bitfield->byteCount != cp->blockBitfield->byteCount ) ) + if( !cp || !tr_bitfieldTestFast( bitfield, cp->tor->blockCount ) ) return TR_ERROR_ASSERT; tr_cpReset( cp ); - i = 0; - while( tr_bitfieldFindTrue( bitfield, i, &i ) ) - tr_cpBlockAdd( cp, i++ ); + for( i=0; itor->blockCount; ++i ) + if( tr_bitfieldHasFast( bitfield, i ) ) + tr_cpBlockAdd( cp, i ); return 0; } diff --git a/libtransmission/completion.h b/libtransmission/completion.h index 615624409..476e7ea98 100644 --- a/libtransmission/completion.h +++ b/libtransmission/completion.h @@ -53,8 +53,6 @@ void tr_cpPieceRem( tr_completion *, tr_piece_index_t piece ); /* Blocks */ int tr_cpBlockIsComplete( const tr_completion *, tr_block_index_t block ); -int tr_cpBlockFindComplete( const tr_completion * cp, - size_t startPos, size_t* foundPos ); void tr_cpBlockAdd( tr_completion *, tr_block_index_t block ); tr_errno tr_cpBlockBitfieldSet( tr_completion *, struct tr_bitfield * ); int tr_cpMissingBlocksInPiece( const tr_completion * cp,