(trunk libT) in tr_torrentFiles(), avoid some expensive calculations if the torrent is a seed.

This commit is contained in:
Charles Kerr 2009-04-12 17:31:17 +00:00
parent a2b53f5cbd
commit cf552651f7
1 changed files with 2 additions and 1 deletions

View File

@ -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 );
}