more array enumeration using blocks and the concurrent option
This commit is contained in:
parent
bc344e6e74
commit
7223a980f3
|
@ -2119,38 +2119,37 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
//check text field
|
||||
if (searchStrings)
|
||||
{
|
||||
BOOL removeTextField = NO;
|
||||
__block BOOL removeTextField = NO;
|
||||
if (filterTracker)
|
||||
{
|
||||
NSArray * trackers = [torrent allTrackersFlat];
|
||||
|
||||
//to count, we need each string in atleast 1 tracker
|
||||
for (NSString * searchString in searchStrings)
|
||||
{
|
||||
BOOL found = NO;
|
||||
for (NSString * tracker in trackers)
|
||||
{
|
||||
//to count, we need each string in at least 1 tracker
|
||||
[searchStrings enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id searchString, NSUInteger idx, BOOL * stop) {
|
||||
__block BOOL found = NO;
|
||||
[trackers enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id tracker, NSUInteger idx, BOOL * stopTracker) {
|
||||
if ([tracker rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)
|
||||
{
|
||||
found = YES;
|
||||
break;
|
||||
*stopTracker = YES;
|
||||
}
|
||||
}
|
||||
}];
|
||||
if (!found)
|
||||
{
|
||||
removeTextField = YES;
|
||||
break;
|
||||
*stop = YES;
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (NSString * searchString in searchStrings)
|
||||
[searchStrings enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id searchString, NSUInteger idx, BOOL * stop) {
|
||||
if ([[torrent name] rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
||||
{
|
||||
removeTextField = YES;
|
||||
break;
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (removeTextField)
|
||||
|
|
|
@ -125,15 +125,16 @@ typedef enum
|
|||
NSArray * tempList = !text ? [fTorrent fileList] : [fTorrent flatFileList];
|
||||
for (FileListNode * item in tempList)
|
||||
{
|
||||
BOOL filter = NO;
|
||||
__block BOOL filter = NO;
|
||||
if (components)
|
||||
{
|
||||
for (NSString * sub in components)
|
||||
if ([[item name] rangeOfString: sub options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
||||
[components enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL * stop) {
|
||||
if ([[item name] rangeOfString: (NSString *)obj options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
||||
{
|
||||
filter = YES;
|
||||
break;
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (!filter)
|
||||
|
|
Loading…
Reference in New Issue