Changeset 13187


Ignore:
Timestamp:
Jan 31, 2012, 4:22:51 AM (7 years ago)
Author:
livings124
Message:

remove redundant code in Torrent's canChangeDownloadCheckForFile:, and enumerate of the files in canChangeDownloadCheckForFiles: concurrently.

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13184 r13187  
    410410    for (NSMenuItem * item in [fSortMenu itemArray])
    411411    {
     412        //assume all sort items are together and the Queue Order item is first
    412413        if ([item action] == @selector(setSort:) && [item tag] != SORT_ORDER_TAG)
    413414        {
  • trunk/macosx/Torrent.m

    r13174 r13187  
    13821382    NSAssert2(index < [self fileCount], @"Index %d is greater than file count %d", index, [self fileCount]);
    13831383   
     1384    return [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]];
     1385}
     1386
     1387- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet
     1388{
    13841389    if ([self fileCount] == 1 || [self isComplete])
    13851390        return NO;
     
    13881393        [self updateFileStat];
    13891394   
    1390     return fFileStat[index].progress < 1.0;
    1391 }
    1392 
    1393 - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet
    1394 {
    1395     if ([self fileCount] == 1 || [self isComplete])
    1396         return NO;
    1397    
    1398     if (!fFileStat)
    1399         [self updateFileStat];
    1400    
    1401     for (NSUInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     1395    __block BOOL canChange = NO;
     1396    [indexSet enumerateIndexesWithOptions: NSEnumerationConcurrent usingBlock: ^(NSUInteger index, BOOL *stop) {
    14021397        if (fFileStat[index].progress < 1.0)
    1403             return YES;
    1404     return NO;
     1398        {
     1399            canChange = YES;
     1400            *stop = YES;
     1401        }
     1402    }];
     1403    return canChange;
    14051404}
    14061405
Note: See TracChangeset for help on using the changeset viewer.