From e6a7986231e276cb0390b7393191b3c6c4ddb903 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 26 Jul 2006 02:54:36 +0000 Subject: [PATCH] Small efficiency change. --- macosx/TorrentTableView.h | 2 ++ macosx/TorrentTableView.m | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 8a688336e..3d2a8be67 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -43,6 +43,8 @@ * fRevealOnIcon, * fRevealOffIcon; NSMutableArray * fKeyStrokes; + + NSDictionary * fSmallStatusAttributes; } - (void) setTorrents: (NSArray *) torrents; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 294e36c20..57d1b3cae 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -63,6 +63,9 @@ fKeyStrokes = [[NSMutableArray alloc] init]; + fSmallStatusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil]; + fDefaults = [NSUserDefaults standardUserDefaults]; } @@ -78,6 +81,7 @@ - (void) dealloc { [fKeyStrokes release]; + [fSmallStatusAttributes release]; [super dealloc]; } @@ -287,13 +291,11 @@ if (row < 0 || ![fDefaults boolForKey: @"SmallView"]) return NO; - NSDictionary * statusAttributes = [NSDictionary dictionaryWithObjectsAndKeys: - [NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil]; Torrent * torrent = [fTorrents objectAtIndex: row]; NSString * statusString = ![fDefaults boolForKey: @"SmallStatusRegular"] && [torrent isActive] && [torrent progress] < 1.0 ? [torrent remainingTimeString] : [torrent shortStatusString]; - float statusWidth = [statusString sizeWithAttributes: statusAttributes].width + 3.0; + float statusWidth = [statusString sizeWithAttributes: fSmallStatusAttributes].width + 3.0; NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row]; NSRect statusRect = NSMakeRect(NSMaxX(cellRect) - statusWidth, cellRect.origin.y,