(trunk libT) simplify tr_torrent's hasAnyLocalData() to be more readable, and also to avoid yet another unnecessary malloc() and free()

This commit is contained in:
Jordan Lee 2011-04-01 04:33:35 +00:00
parent c54f469c39
commit 2328456a4a
1 changed files with 4 additions and 13 deletions

View File

@ -762,21 +762,12 @@ static bool
hasAnyLocalData( const tr_torrent * tor )
{
tr_file_index_t i;
bool has_local_data = false;
const tr_file_index_t n = tor->info.fileCount;
for( i=0; i<n && !has_local_data; ++i )
{
struct stat sb;
char * filename = tr_torrentFindFile( tor, i );
for( i=0; i<tor->info.fileCount; ++i )
if( tr_torrentFindFile2( tor, i, NULL, NULL ) )
return true;
if( filename && !stat( filename, &sb ) )
has_local_data = true;
tr_free( filename );
}
return has_local_data;
return false;
}
static bool