mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
update the file table node search to (possibly) use concurrent enumeration
This commit is contained in:
parent
9c75df7ddc
commit
bc344e6e74
1 changed files with 10 additions and 9 deletions
|
@ -587,24 +587,25 @@ typedef enum
|
|||
{
|
||||
NSAssert(![node isFolder], @"Looking up folder node!");
|
||||
|
||||
const NSUInteger nodeIndex = [[node indexes] firstIndex];
|
||||
for (NSUInteger index = range.location; index < NSMaxRange(range); ++index)
|
||||
{
|
||||
FileListNode * checkNode = [list objectAtIndex: index];
|
||||
__block NSUInteger retIndex = NSNotFound;
|
||||
|
||||
[list enumerateObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: range] options: NSEnumerationConcurrent usingBlock: ^(id checkNode, NSUInteger index, BOOL * stop) {
|
||||
if ([checkNode isEqualTo: node])
|
||||
{
|
||||
*parent = currentParent;
|
||||
return index;
|
||||
retIndex = index;
|
||||
*stop = YES;
|
||||
}
|
||||
else if ([checkNode isFolder] && [[checkNode indexes] containsIndex: nodeIndex])
|
||||
else if ([checkNode isFolder] && [[checkNode indexes] containsIndex: [[node indexes] firstIndex]])
|
||||
{
|
||||
const NSUInteger subIndex = [self findFileNode: node inList: [checkNode children] inRange: NSMakeRange(0, [[checkNode children] count]) currentParent: checkNode finalParent: parent];
|
||||
NSAssert(subIndex != NSNotFound, @"We didn't find an expected file node.");
|
||||
return subIndex;
|
||||
retIndex = subIndex;
|
||||
*stop = YES;
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
return NSNotFound;
|
||||
return retIndex;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue