avoid needlessly copying the folder icon

This commit is contained in:
Mitchell Livingston
2009-12-27 19:30:20 +00:00
parent 37c0f8cfa8
commit c242a19eaf
3 changed files with 4 additions and 19 deletions

View File

@@ -115,8 +115,9 @@
- (NSImage *) icon
{
if (!fIsFolder && !fIcon)
fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: [fName pathExtension]] retain];
if (!fIcon)
fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: fIsFolder ? NSFileTypeForHFSTypeCode('fldr')
: [fName pathExtension]] retain];
return fIcon;
}

View File

@@ -26,8 +26,6 @@
@interface FileNameCell : NSActionCell
{
NSImage * fFolderImage;
NSMutableDictionary * fTitleAttributes, * fStatusAttributes;
}

View File

@@ -74,8 +74,6 @@
[fTitleAttributes release];
[fStatusAttributes release];
[fFolderImage release];
[super dealloc];
}
@@ -86,25 +84,13 @@
copy->fTitleAttributes = [fTitleAttributes retain];
copy->fStatusAttributes = [fStatusAttributes retain];
copy->fFolderImage = [fFolderImage retain];
return copy;
}
- (NSImage *) image
{
FileListNode * node = (FileListNode *)[self objectValue];
NSImage * image;
if ([node isFolder])
{
if (!fFolderImage)
fFolderImage = [[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')] copy];
image = fFolderImage;
}
else
image = [node icon];
return image;
return [node icon];
}
- (NSRect) imageRectForBounds: (NSRect) bounds