1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 18:18:10 +00:00

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"]) if ([self.fDefaults boolForKey:@"AutoSize"])
{ {
NSUInteger groups = (self.fDisplayedTorrents.count > 0 && ![self.fDisplayedTorrents[0] isKindOfClass:[Torrent class]]) ? NSUInteger groups = ![self.fDisplayedTorrents.firstObject isKindOfClass:[Torrent class]] ? self.fDisplayedTorrents.count : 0;
self.fDisplayedTorrents.count :
0;
height = (kGroupSeparatorHeight + self.fTableView.intercellSpacing.height) * groups + height = (kGroupSeparatorHeight + self.fTableView.intercellSpacing.height) * groups +
(self.fTableView.rowHeight + self.fTableView.intercellSpacing.height) * (self.fTableView.numberOfRows - 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; NSUInteger count = indexSet.count;
tr_file_index_t* files = static_cast<tr_file_index_t*>(malloc(count * sizeof(tr_file_index_t))); 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++) [indexSet getIndexes:files maxCount:count inIndexRange:nil];
{
files[i] = index;
}
tr_torrentSetFileDLs(self.fHandle, files, count, state != NSControlStateValueOff); tr_torrentSetFileDLs(self.fHandle, files, count, state != NSControlStateValueOff);
free(files); free(files);