From c824db3f85a097a5fc78a80902eebb8b42ac9b01 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 7 Nov 2009 04:48:02 +0000 Subject: [PATCH] small efficiency change for file inspector stats --- macosx/Torrent.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index ff147ce1b..d35dc18b3 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1229,6 +1229,9 @@ int trashDataFile(const char * filename) if ([self isComplete]) return 1.0; + if ([self fileCount] == 1) + return [self progress]; + if (!fFileStat) [self updateFileStat]; @@ -1252,15 +1255,20 @@ int trashDataFile(const char * filename) - (BOOL) canChangeDownloadCheckForFile: (NSInteger) index { + NSAssert2(index < [self fileCount], @"Index %d is greater than file count %d", index, [self fileCount]); + + if ([self fileCount] == 1 || [self isComplete]) + return NO; + if (!fFileStat) [self updateFileStat]; - return [self fileCount] > 1 && fFileStat[index].progress < 1.0; + return fFileStat[index].progress < 1.0; } - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet { - if ([self fileCount] <= 1 || [self isComplete]) + if ([self fileCount] == 1 || [self isComplete]) return NO; if (!fFileStat)