mirror of
https://github.com/transmission/transmission
synced 2025-03-04 10:38:13 +00:00
concurrent enumeration when generating a torrent's file list
This commit is contained in:
parent
f05360e5a3
commit
a0abfd79c0
2 changed files with 10 additions and 5 deletions
|
@ -33,7 +33,9 @@
|
|||
[coloredImage lockFocus];
|
||||
|
||||
[color set];
|
||||
NSRectFillUsingOperation(NSMakeRect(0.0, 0.0, [coloredImage size].width, [coloredImage size].height), NSCompositeSourceAtop);
|
||||
|
||||
const NSSize size = [coloredImage size];
|
||||
NSRectFillUsingOperation(NSMakeRect(0.0, 0.0, size.width, size.height), NSCompositeSourceAtop);
|
||||
|
||||
[coloredImage unlockFocus];
|
||||
|
||||
|
|
|
@ -1761,9 +1761,11 @@ int trashDataFile(const char * filename)
|
|||
FileListNode * node = nil;
|
||||
if (isFolder)
|
||||
{
|
||||
for (node in [parent children])
|
||||
if ([[node name] isEqualToString: name] && [node isFolder])
|
||||
break;
|
||||
const NSUInteger nodeIndex = [[parent children] indexOfObjectWithOptions: NSEnumerationConcurrent passingTest: ^BOOL(FileListNode * searchNode, NSUInteger idx, BOOL * stop) {
|
||||
return [[searchNode name] isEqualToString: name] && [searchNode isFolder];
|
||||
}];
|
||||
if (nodeIndex != NSNotFound)
|
||||
node = [[parent children] objectAtIndex: nodeIndex];
|
||||
}
|
||||
|
||||
//create new folder or file if it doesn't already exist
|
||||
|
@ -1796,9 +1798,10 @@ int trashDataFile(const char * filename)
|
|||
NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"name" ascending: YES selector: @selector(localizedStandardCompare:)];
|
||||
[fileNodes sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
|
||||
|
||||
for (FileListNode * node in fileNodes)
|
||||
[fileNodes enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(FileListNode * node, NSUInteger idx, BOOL * stop) {
|
||||
if ([node isFolder])
|
||||
[self sortFileList: [node children]];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void) startQueue
|
||||
|
|
Loading…
Add table
Reference in a new issue