(trunk libT) #4684 "tr_cpSizeWhenDone() is slow for huge torrents that we're only partially downloading" -- fixed.

There are actually two different implementations of the byte-counting in that function: a slower implementation was added prior to 2.40 in r12918 to double-check the standard implementation. This checking was added to help smoke out a bug that was fixed in r12920, but I forgot to remove that slower implementation.
This commit is contained in:
Jordan Lee 2011-12-22 19:35:13 +00:00
parent 9576dd16e2
commit a8468a7b09
1 changed files with 4 additions and 10 deletions

View File

@ -165,19 +165,13 @@ tr_cpSizeWhenDone( const tr_completion * ccp )
}
else
{
uint64_t o = 0;
tr_block_index_t b, f, l;
tr_block_index_t f, l;
tr_torGetPieceBlockRange( cp->tor, p, &f, &l );
for( b=f; b<=l; ++b )
if( tr_cpBlockIsComplete( cp, b ) )
n += tr_torBlockCountBytes( tor, b );
o = tr_bitfieldCountRange( &cp->blockBitfield, f, l+1 );
o *= cp->tor->blockSize;
n = tr_bitfieldCountRange( &cp->blockBitfield, f, l+1 );
n *= cp->tor->blockSize;
if( l == ( cp->tor->blockCount - 1 ) && tr_bitfieldHas( &cp->blockBitfield, l ) )
o -= ( cp->tor->blockSize - cp->tor->lastBlockSize );
assert( n == o );
n -= ( cp->tor->blockSize - cp->tor->lastBlockSize );
}
assert( n <= tr_torPieceCountBytes( tor, p ) );