Use NSIndexSet getIndexes:maxCount:inIndexRange: directly (#4179)

This commit is contained in:
A Cœur 2022-11-28 13:10:03 +08:00 committed by GitHub
parent 9a6fbc9ced
commit e4276a3018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 7 deletions

View File

@ -5330,9 +5330,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
if ([self.fDefaults boolForKey:@"AutoSize"])
{
NSUInteger groups = (self.fDisplayedTorrents.count > 0 && ![self.fDisplayedTorrents[0] isKindOfClass:[Torrent class]]) ?
self.fDisplayedTorrents.count :
0;
NSUInteger groups = ![self.fDisplayedTorrents.firstObject isKindOfClass:[Torrent class]] ? self.fDisplayedTorrents.count : 0;
height = (kGroupSeparatorHeight + self.fTableView.intercellSpacing.height) * groups +
(self.fTableView.rowHeight + self.fTableView.intercellSpacing.height) * (self.fTableView.numberOfRows - groups);

View File

@ -1484,10 +1484,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error** error)
{
NSUInteger count = indexSet.count;
tr_file_index_t* files = static_cast<tr_file_index_t*>(malloc(count * sizeof(tr_file_index_t)));
for (NSUInteger index = indexSet.firstIndex, i = 0; index != NSNotFound; index = [indexSet indexGreaterThanIndex:index], i++)
{
files[i] = index;
}
[indexSet getIndexes:files maxCount:count inIndexRange:nil];
tr_torrentSetFileDLs(self.fHandle, files, count, state != NSControlStateValueOff);
free(files);