From a84f0cd9e6a47ac1a6048b9a284794f0b4505049 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 8 Aug 2007 16:14:52 +0000 Subject: [PATCH] small optimization in obtaining error image --- macosx/TorrentCell.m | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index abceb41b8..9f1fb2cd0 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -40,7 +40,7 @@ @implementation TorrentCell -#warning release? +//only called one, so don't worry about release - (id) init { if ((self = [super init])) @@ -58,9 +58,6 @@ fYellowGradient = [[CTGradient progressYellowGradient] retain]; fTransparentGradient = [[CTGradient progressTransparentGradient] retain]; - fErrorImage = [[NSImage imageNamed: @"Error.png"] copy]; - [fErrorImage setFlipped: YES]; - NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; @@ -207,6 +204,12 @@ //error badge if ([[info objectForKey: @"Error"] boolValue]) { + if (!fErrorImage) + { + fErrorImage = [[NSImage imageNamed: @"Error.png"] copy]; + [fErrorImage setFlipped: YES]; + } + NSSize errorIconSize = [fErrorImage size]; [fErrorImage drawAtPoint: NSMakePoint(pen.x + iconSize.width - errorIconSize.width, pen.y + iconSize.height - errorIconSize.height) @@ -253,7 +256,18 @@ else //small size { //icon - NSImage * icon = ![[info objectForKey: @"Error"] boolValue] ? [info objectForKey: @"Icon"] : fErrorImage; + NSImage * icon; + if ([[info objectForKey: @"Error"] boolValue]) + { + if (!fErrorImage) + { + fErrorImage = [[NSImage imageNamed: @"Error.png"] copy]; + [fErrorImage setFlipped: YES]; + } + icon = fErrorImage; + } + else + icon = [info objectForKey: @"Icon"]; NSSize iconSize = [icon size]; pen.x += PADDING;