From 339005346cd1fc8ef4bb74c184cf57120ce91157 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jul 2007 17:08:45 +0000 Subject: [PATCH] remove unused function tr_cpMostMissingBlockInPiece() --- libtransmission/completion.c | 48 ------------------------------------ libtransmission/completion.h | 2 -- libtransmission/peer.c | 4 +-- libtransmission/torrent.c | 11 ++++----- 4 files changed, 6 insertions(+), 59 deletions(-) diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 3a26e83dd..d95173451 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -230,54 +230,6 @@ int tr_cpMissingBlockInPiece( const tr_completion_t * cp, int piece ) return -1; } -int tr_cpMostMissingBlockInPiece( const tr_completion_t * cp, - int piece, - int * downloaders ) -{ - tr_torrent_t * tor = cp->tor; - int start, count, end, i; - int * pool, poolSize, min, ret; - - start = tr_pieceStartBlock( piece ); - count = tr_cpCountBlocks( cp, piece ); - end = start + count; - - pool = tr_new( int, count ); - poolSize = 0; - min = 255; - - for( i = start; i < end; i++ ) - { - if( tr_cpBlockIsComplete( cp, i ) || cp->blockDownloaders[i] > min ) - { - continue; - } - if( cp->blockDownloaders[i] < min ) - { - min = cp->blockDownloaders[i]; - poolSize = 0; - } - if( cp->blockDownloaders[i] <= min ) - { - pool[poolSize++] = i; - } - } - - if( poolSize > 0 ) - { - ret = pool[0]; - *downloaders = min; - } - else - { - ret = -1; - } - - tr_free( pool ); - return ret; -} - - /*** **** ***/ diff --git a/libtransmission/completion.h b/libtransmission/completion.h index 79acbcb60..5c7abf36e 100644 --- a/libtransmission/completion.h +++ b/libtransmission/completion.h @@ -59,7 +59,5 @@ float tr_cpPercentBlocksInPiece( const tr_completion_t * cp, int /* Missing = we don't have it and we are not getting it from any peer yet */ int tr_cpMissingBlocksForPiece( const tr_completion_t * cp, int piece ); int tr_cpMissingBlockInPiece( const tr_completion_t *, int piece ); -int tr_cpMostMissingBlockInPiece( const tr_completion_t *, int piece, - int * downloaders ); #endif diff --git a/libtransmission/peer.c b/libtransmission/peer.c index febd89051..589bbf30d 100644 --- a/libtransmission/peer.c +++ b/libtransmission/peer.c @@ -668,9 +668,7 @@ writeEnd: { int unused; const int piece = pool[i]; - const int block = endgame - ? tr_cpMostMissingBlockInPiece( tor->completion, piece, &unused) - : tr_cpMissingBlockInPiece ( tor->completion, piece ); + const int block = tr_cpMissingBlockInPiece ( tor->completion, piece ); if( block>=0 ) sendRequest( tor, peer, block ); diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 78e44305c..143029596 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -1372,6 +1372,11 @@ int _tr_blockPiece( const tr_torrent_t * tor, int block ) return (block * tor->blockSize) / tor->info.pieceSize; } +int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece ) +{ + return (piece * tor->info.pieceSize) / tor->blockSize; +} + int _tr_blockSize( const tr_torrent_t * tor, int block ) { const tr_info_t * inf = &tor->info; @@ -1397,12 +1402,6 @@ int _tr_pieceCountBlocks( const tr_torrent_t * tor, int piece ) return tor->blockCount % ( inf->pieceSize / tor->blockSize ); } -int _tr_pieceStartBlock( const tr_torrent_t * tor, int piece ) -{ - const tr_info_t * inf = &tor->info; - return piece * ( inf->pieceSize / tor->blockSize ); -} - int _tr_pieceSize( const tr_torrent_t * tor, int piece ) { const tr_info_t * inf = &tor->info;