1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

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

This commit is contained in:
Mitchell Livingston 2012-01-31 04:22:51 +00:00
parent d7842c0925
commit 480700e835
2 changed files with 10 additions and 10 deletions

View file

@ -409,6 +409,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
BOOL foundSortItem = NO;
for (NSMenuItem * item in [fSortMenu itemArray])
{
//assume all sort items are together and the Queue Order item is first
if ([item action] == @selector(setSort:) && [item tag] != SORT_ORDER_TAG)
{
[sortMenuItems addObject: item];

View file

@ -1381,13 +1381,7 @@ int trashDataFile(const char * filename)
{
NSAssert2(index < [self fileCount], @"Index %d is greater than file count %d", index, [self fileCount]);
if ([self fileCount] == 1 || [self isComplete])
return NO;
if (!fFileStat)
[self updateFileStat];
return fFileStat[index].progress < 1.0;
return [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]];
}
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet
@ -1398,10 +1392,15 @@ int trashDataFile(const char * filename)
if (!fFileStat)
[self updateFileStat];
for (NSUInteger index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
__block BOOL canChange = NO;
[indexSet enumerateIndexesWithOptions: NSEnumerationConcurrent usingBlock: ^(NSUInteger index, BOOL *stop) {
if (fFileStat[index].progress < 1.0)
return YES;
return NO;
{
canChange = YES;
*stop = YES;
}
}];
return canChange;
}
- (NSInteger) checkForFiles: (NSIndexSet *) indexSet