1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-21 21:57:01 +00:00

search for folder nodes concurrently when generating a torrent's file list

This commit is contained in:
Mitchell Livingston 2012-01-14 16:07:58 +00:00
parent bfc288a309
commit 1b4ec4dc4d

View file

@ -1710,10 +1710,14 @@ int trashDataFile(const char * filename)
if ([pathComponents count] > 2)
{
//determine if folder node already exists
FileListNode * node;
for (node in fileList)
if ([[node name] isEqualToString: name] && [node isFolder])
break;
__block FileListNode * node = nil;
[fileList enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(FileListNode * searchNode, NSUInteger idx, BOOL * stop) {
if ([[searchNode name] isEqualToString: name] && [searchNode isFolder])
{
node = searchNode;
*stop = YES;
}
}];
if (!node)
{
@ -1722,8 +1726,7 @@ int trashDataFile(const char * filename)
[node release];
}
NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange:
NSMakeRange(2, [pathComponents count]-2)]];
NSMutableArray * trimmedComponents = [NSMutableArray arrayWithArray: [pathComponents subarrayWithRange: NSMakeRange(2, [pathComponents count]-2)]];
[node insertIndex: i withSize: file->length];
[self insertPath: trimmedComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
@ -1758,6 +1761,7 @@ int trashDataFile(const char * filename)
NSString * name = [components objectAtIndex: 0];
const BOOL isFolder = [components count] > 1;
//determine if folder node already exists
__block FileListNode * node = nil;
if (isFolder)
{