mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
Use concurrent enumeration when generating the list of filtered torrents.
This commit is contained in:
parent
a43f649935
commit
27595b4888
1 changed files with 12 additions and 13 deletions
|
@ -2057,7 +2057,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
if (!onLion)
|
if (!onLion)
|
||||||
selectedValues = [fTableView selectedValues];
|
selectedValues = [fTableView selectedValues];
|
||||||
|
|
||||||
NSUInteger active = 0, downloading = 0, seeding = 0, paused = 0;
|
__block NSUInteger active = 0, downloading = 0, seeding = 0, paused = 0;
|
||||||
NSString * filterType = [fDefaults stringForKey: @"Filter"];
|
NSString * filterType = [fDefaults stringForKey: @"Filter"];
|
||||||
BOOL filterActive = NO, filterDownload = NO, filterSeed = NO, filterPause = NO, filterStatus = YES;
|
BOOL filterActive = NO, filterDownload = NO, filterSeed = NO, filterPause = NO, filterStatus = YES;
|
||||||
if ([filterType isEqualToString: FILTER_ACTIVE])
|
if ([filterType isEqualToString: FILTER_ACTIVE])
|
||||||
|
@ -2079,11 +2079,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
searchStrings = nil;
|
searchStrings = nil;
|
||||||
const BOOL filterTracker = searchStrings && [[fDefaults stringForKey: @"FilterSearchType"] isEqualToString: FILTER_TYPE_TRACKER];
|
const BOOL filterTracker = searchStrings && [[fDefaults stringForKey: @"FilterSearchType"] isEqualToString: FILTER_TYPE_TRACKER];
|
||||||
|
|
||||||
NSMutableArray * allTorrents = [NSMutableArray arrayWithCapacity: [fTorrents count]];
|
//filter & get counts of each type
|
||||||
|
NSIndexSet * indexesOfNonFilteredTorrents = [fTorrents indexesOfObjectsWithOptions: NSEnumerationConcurrent passingTest: ^BOOL(Torrent * torrent, NSUInteger idx, BOOL * stop) {
|
||||||
//get count of each type
|
|
||||||
for (Torrent * torrent in fTorrents)
|
|
||||||
{
|
|
||||||
//check status
|
//check status
|
||||||
if ([torrent isActive] && ![torrent isCheckingWaiting])
|
if ([torrent isActive] && ![torrent isCheckingWaiting])
|
||||||
{
|
{
|
||||||
|
@ -2095,26 +2092,26 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
{
|
{
|
||||||
++seeding;
|
++seeding;
|
||||||
if (filterStatus && !((filterActive && isActive) || filterSeed))
|
if (filterStatus && !((filterActive && isActive) || filterSeed))
|
||||||
continue;
|
return NO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++downloading;
|
++downloading;
|
||||||
if (filterStatus && !((filterActive && isActive) || filterDownload))
|
if (filterStatus && !((filterActive && isActive) || filterDownload))
|
||||||
continue;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++paused;
|
++paused;
|
||||||
if (filterStatus && !filterPause)
|
if (filterStatus && !filterPause)
|
||||||
continue;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
//checkGroup
|
//checkGroup
|
||||||
if (filterGroup)
|
if (filterGroup)
|
||||||
if ([torrent groupValue] != groupFilterValue)
|
if ([torrent groupValue] != groupFilterValue)
|
||||||
continue;
|
return NO;
|
||||||
|
|
||||||
//check text field
|
//check text field
|
||||||
if (searchStrings)
|
if (searchStrings)
|
||||||
|
@ -2153,11 +2150,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removeTextField)
|
if (removeTextField)
|
||||||
continue;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
[allTorrents addObject: torrent];
|
return YES;
|
||||||
}
|
}];
|
||||||
|
|
||||||
|
NSArray * allTorrents = [fTorrents objectsAtIndexes: indexesOfNonFilteredTorrents];
|
||||||
|
|
||||||
//set button tooltips
|
//set button tooltips
|
||||||
if (fFilterBar)
|
if (fFilterBar)
|
||||||
|
|
Loading…
Reference in a new issue