Changeset 10126


Ignore:
Timestamp:
Feb 7, 2010, 1:56:17 AM (12 years ago)
Author:
livings124
Message:

if no webseeds, avoid some unneeded work when generating the list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.m

    r10106 r10126  
    891891- (NSArray *) webSeeds
    892892{
    893     const NSInteger webSeedCount = fInfo->webseedCount;
    894     NSMutableArray * webSeeds = [NSMutableArray arrayWithCapacity: webSeedCount];
    895    
    896     float * dlSpeeds = tr_torrentWebSpeeds(fHandle);
    897    
    898     for (NSInteger i = 0; i < webSeedCount; i++)
    899     {
    900         NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 3];
    901        
    902         [dict setObject: [self name] forKey: @"Name"];
    903         [dict setObject: [NSString stringWithUTF8String: fInfo->webseeds[i]] forKey: @"Address"];
    904        
    905         if (dlSpeeds[i] != -1.0)
    906             [dict setObject: [NSNumber numberWithFloat: dlSpeeds[i]] forKey: @"DL From Rate"];
    907        
    908         [webSeeds addObject: dict];
    909     }
    910    
    911     tr_free(dlSpeeds);
     893    NSMutableArray * webSeeds = [NSMutableArray arrayWithCapacity: fInfo->webseedCount];
     894   
     895    if (fInfo->webseedCount > 0)
     896    {
     897        float * dlSpeeds = tr_torrentWebSpeeds(fHandle);
     898       
     899        for (NSInteger i = 0; i < fInfo->webseedCount; i++)
     900        {
     901            NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 3];
     902           
     903            [dict setObject: [self name] forKey: @"Name"];
     904            [dict setObject: [NSString stringWithUTF8String: fInfo->webseeds[i]] forKey: @"Address"];
     905           
     906            if (dlSpeeds[i] != -1.0)
     907                [dict setObject: [NSNumber numberWithFloat: dlSpeeds[i]] forKey: @"DL From Rate"];
     908           
     909            [webSeeds addObject: dict];
     910        }
     911       
     912        tr_free(dlSpeeds);
     913    }
    912914   
    913915    return webSeeds;
Note: See TracChangeset for help on using the changeset viewer.