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
|
//check text field
|
||||||
if (searchStrings)
|
if (searchStrings)
|
||||||
{
|
{
|
||||||
BOOL removeTextField = NO;
|
__block BOOL removeTextField = NO;
|
||||||
if (filterTracker)
|
if (filterTracker)
|
||||||
{
|
{
|
||||||
NSArray * trackers = [torrent allTrackersFlat];
|
NSArray * trackers = [torrent allTrackersFlat];
|
||||||
|
|
||||||
//to count, we need each string in atleast 1 tracker
|
//to count, we need each string in at least 1 tracker
|
||||||
for (NSString * searchString in searchStrings)
|
[searchStrings enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id searchString, NSUInteger idx, BOOL * stop) {
|
||||||
{
|
__block BOOL found = NO;
|
||||||
BOOL found = NO;
|
[trackers enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id tracker, NSUInteger idx, BOOL * stopTracker) {
|
||||||
for (NSString * tracker in trackers)
|
|
||||||
{
|
|
||||||
if ([tracker rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)
|
if ([tracker rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)
|
||||||
{
|
{
|
||||||
found = YES;
|
found = YES;
|
||||||
break;
|
*stopTracker = YES;
|
||||||
}
|
}
|
||||||
}
|
}];
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
removeTextField = YES;
|
removeTextField = YES;
|
||||||
break;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
}
|
}];
|
||||||
}
|
}
|
||||||
else
|
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)
|
if ([[torrent name] rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
||||||
{
|
{
|
||||||
removeTextField = YES;
|
removeTextField = YES;
|
||||||
break;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removeTextField)
|
if (removeTextField)
|
||||||
|
|
|
@ -125,15 +125,16 @@ typedef enum
|
||||||
NSArray * tempList = !text ? [fTorrent fileList] : [fTorrent flatFileList];
|
NSArray * tempList = !text ? [fTorrent fileList] : [fTorrent flatFileList];
|
||||||
for (FileListNode * item in tempList)
|
for (FileListNode * item in tempList)
|
||||||
{
|
{
|
||||||
BOOL filter = NO;
|
__block BOOL filter = NO;
|
||||||
if (components)
|
if (components)
|
||||||
{
|
{
|
||||||
for (NSString * sub in components)
|
[components enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL * stop) {
|
||||||
if ([[item name] rangeOfString: sub options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
if ([[item name] rangeOfString: (NSString *)obj options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound)
|
||||||
{
|
{
|
||||||
filter = YES;
|
filter = YES;
|
||||||
break;
|
*stop = YES;
|
||||||
}
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
|
|
Loading…
Reference in New Issue