From e4276a3018f9824f54acc8296a16d04294486e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=20C=C5=93ur?= Date: Mon, 28 Nov 2022 13:10:03 +0800 Subject: [PATCH] Use NSIndexSet getIndexes:maxCount:inIndexRange: directly (#4179) --- macosx/Controller.mm | 4 +--- macosx/Torrent.mm | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 3af24299c..90365127a 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -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); diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index d0ee1d7c7..53d01eb13 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -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(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);