From 32237dbdb0c663284fc81e3fdb87ce704c3e92e6 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Mon, 21 Feb 2011 15:36:07 +0000 Subject: [PATCH] (trunk libT) remove unused functions: tr_bitsetDifference() tr_bitfieldDifference() --- libtransmission/bitfield.c | 13 ------------- libtransmission/bitfield.h | 2 -- libtransmission/bitset.c | 10 ---------- libtransmission/bitset.h | 3 --- libtransmission/peer-mgr.c | 25 ++----------------------- 5 files changed, 2 insertions(+), 51 deletions(-) diff --git a/libtransmission/bitfield.c b/libtransmission/bitfield.c index 2563ca9a6..45b6c728b 100644 --- a/libtransmission/bitfield.c +++ b/libtransmission/bitfield.c @@ -173,19 +173,6 @@ tr_bitfieldOr( tr_bitfield * a, const tr_bitfield * b ) return a; } -/* set 'a' to all the flags that were in 'a' but not 'b' */ -void -tr_bitfieldDifference( tr_bitfield * a, const tr_bitfield * b ) -{ - uint8_t * ait = a->bits; - const uint8_t * aend = ait + a->byteCount; - const uint8_t * bit = b->bits; - const uint8_t * bend = bit + b->byteCount; - - while( ait!=aend && bit!=bend ) - *ait++ &= ~( *bit++ ); -} - size_t tr_bitfieldCountTrueBits( const tr_bitfield* b ) { diff --git a/libtransmission/bitfield.h b/libtransmission/bitfield.h index cab952b3e..81939a665 100644 --- a/libtransmission/bitfield.h +++ b/libtransmission/bitfield.h @@ -55,8 +55,6 @@ int tr_bitfieldAddRange( tr_bitfield *, size_t begin, size_t end ); int tr_bitfieldRemRange( tr_bitfield*, size_t begin, size_t end ); -void tr_bitfieldDifference( tr_bitfield *, const tr_bitfield * ); - int tr_bitfieldIsEmpty( const tr_bitfield* ); size_t tr_bitfieldCountTrueBits( const tr_bitfield* ); diff --git a/libtransmission/bitset.c b/libtransmission/bitset.c index 82c6360f0..c01d02cd7 100644 --- a/libtransmission/bitset.c +++ b/libtransmission/bitset.c @@ -60,16 +60,6 @@ tr_bitsetOr( tr_bitfield * a, const tr_bitset * b ) tr_bitfieldOr( a, &b->bitfield ); } -/* set 'a' to all the flags that were in 'a' but not 'b' */ -void -tr_bitsetDifference( tr_bitfield * a, const tr_bitset * b ) -{ - if( b->haveAll ) - tr_bitfieldClear( a ); - else if( !b->haveNone ) - tr_bitfieldDifference( a, &b->bitfield ); -} - double tr_bitsetPercent( const tr_bitset * b ) { diff --git a/libtransmission/bitset.h b/libtransmission/bitset.h index 7fc842975..0afc8a98a 100644 --- a/libtransmission/bitset.h +++ b/libtransmission/bitset.h @@ -48,7 +48,4 @@ tr_bool tr_bitsetHas( const tr_bitset * b, const size_t nth ); void tr_bitsetOr( tr_bitfield * a, const tr_bitset * b ); -/* set 'a' to all the flags that were in 'a' but not 'b' */ -void tr_bitsetDifference( tr_bitfield * a, const tr_bitset * b ); - #endif diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 34c07854e..122674d10 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -3105,29 +3105,8 @@ shouldPeerBeClosed( const Torrent * t, /* if we're seeding and the peer has everything we have, * and enough time has passed for a pex exchange, then disconnect */ - if( tr_torrentIsSeed( tor ) ) - { - tr_bool peerHasEverything; - - if( atom->seedProbability != -1 ) - { - peerHasEverything = atomIsSeed( atom ); - } - else - { - tr_bitfield * tmp = tr_bitfieldDup( tr_cpPieceBitfield( &tor->completion ) ); - tr_bitsetDifference( tmp, &peer->have ); - peerHasEverything = tr_bitfieldCountTrueBits( tmp ) == 0; - tr_bitfieldFree( tmp ); - } - - if( peerHasEverything && ( !tr_torrentAllowsPex(tor) || (now-atom->time>=30 ))) - { - tordbg( t, "purging peer %s because we're both seeds", - tr_atomAddrStr( atom ) ); - return TRUE; - } - } + if( tr_torrentIsSeed( tor ) && ( peer->progress >= 1.0f ) ) + return !tr_torrentAllowsPex(tor) || (now-atom->time>=30); /* disconnect if it's been too long since piece data has been transferred. * this is on a sliding scale based on number of available peers... */