Changeset 13143


Ignore:
Timestamp:
Jan 8, 2012, 5:05:47 AM (10 years ago)
Author:
livings124
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileOutlineController.m

    r13142 r13143  
    588588    NSAssert(![node isFolder], @"Looking up folder node!");
    589589   
    590     const NSUInteger nodeIndex = [[node indexes] firstIndex];
    591     for (NSUInteger index = range.location; index < NSMaxRange(range); ++index)
    592     {
    593         FileListNode * checkNode = [list objectAtIndex: index];
     590    __block NSUInteger retIndex = NSNotFound;
     591   
     592    [list enumerateObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: range] options: NSEnumerationConcurrent usingBlock: ^(id checkNode, NSUInteger index, BOOL * stop) {
    594593        if ([checkNode isEqualTo: node])
    595594        {
    596595            *parent = currentParent;
    597             return index;
    598         }
    599         else if ([checkNode isFolder] && [[checkNode indexes] containsIndex: nodeIndex])
     596            retIndex = index;
     597            *stop = YES;
     598        }
     599        else if ([checkNode isFolder] && [[checkNode indexes] containsIndex: [[node indexes] firstIndex]])
    600600        {
    601601            const NSUInteger subIndex = [self findFileNode: node inList: [checkNode children] inRange: NSMakeRange(0, [[checkNode children] count]) currentParent: checkNode finalParent: parent];
    602602            NSAssert(subIndex != NSNotFound, @"We didn't find an expected file node.");
    603             return subIndex;
    604         }
    605     }
    606    
    607     return NSNotFound;
     603            retIndex = subIndex;
     604            *stop = YES;
     605        }
     606    }];
     607   
     608    return retIndex;
    608609}
    609610
Note: See TracChangeset for help on using the changeset viewer.