From a8468a7b09ce20e766cff992e847844510887722 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 22 Dec 2011 19:35:13 +0000 Subject: [PATCH] (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. --- libtransmission/completion.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 7004086c9..c0538c439 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -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 ) );