update the file table node search to (possibly) use concurrent enumeration

This commit is contained in:
Mitchell Livingston 2012-01-08 05:05:47 +00:00
parent 9c75df7ddc
commit bc344e6e74
1 changed files with 10 additions and 9 deletions

View File

@ -587,24 +587,25 @@ typedef enum
{ {
NSAssert(![node isFolder], @"Looking up folder node!"); NSAssert(![node isFolder], @"Looking up folder node!");
const NSUInteger nodeIndex = [[node indexes] firstIndex]; __block NSUInteger retIndex = NSNotFound;
for (NSUInteger index = range.location; index < NSMaxRange(range); ++index)
{ [list enumerateObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: range] options: NSEnumerationConcurrent usingBlock: ^(id checkNode, NSUInteger index, BOOL * stop) {
FileListNode * checkNode = [list objectAtIndex: index];
if ([checkNode isEqualTo: node]) if ([checkNode isEqualTo: node])
{ {
*parent = currentParent; *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]; 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."); NSAssert(subIndex != NSNotFound, @"We didn't find an expected file node.");
return subIndex; retIndex = subIndex;
*stop = YES;
} }
} }];
return NSNotFound; return retIndex;
} }
@end @end