From cf552651f79b1e3eedf58e5104ca098d48d60ef3 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 12 Apr 2009 17:31:17 +0000 Subject: [PATCH] (trunk libT) in tr_torrentFiles(), avoid some expensive calculations if the torrent is a seed. --- libtransmission/torrent.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index e7f6ea884..5715342f4 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -1042,12 +1042,13 @@ tr_torrentFiles( const tr_torrent * tor, const tr_file_index_t n = tor->info.fileCount; tr_file_stat * files = tr_new0( tr_file_stat, n ); tr_file_stat * walk = files; + const tr_bool isSeed = tor->completeness == TR_SEED; assert( tr_isTorrent( tor ) ); for( i = 0; i < n; ++i, ++walk ) { - const uint64_t b = fileBytesCompleted( tor, i ); + const uint64_t b = isSeed ? tor->info.files[i].length : fileBytesCompleted( tor, i ); walk->bytesCompleted = b; walk->progress = tr_getRatio( b, tor->info.files[i].length ); }