Re-use file icon image

These are expensive to create and it was noticeable when lots of files matched and the menu had to be created (as it would when the user press a potential menu key like ⌘W).
This commit is contained in:
Allan Odgaard
2013-02-18 15:34:29 +01:00
parent 81f8cc4e29
commit e62ef9cf6d

View File

@@ -289,7 +289,7 @@ struct operation_t
std::string const& title = doc->path() == NULL_STR ? doc->display_name() : path::relative_to(doc->path(), [[self rootPath] UTF8String]);
NSString* shortcut = key < 11 ? [NSString stringWithFormat:@"%lu", (key++ % 10)] : @"";
NSMenuItem* item = [menu addItemWithTitle:[NSString stringWithCxxString:title] action:@selector(selectMatchingPath:) keyEquivalent:shortcut];
[item setIconForFile:match.path];
[item setImage:match.icon];
[item setRepresentedObject:match.path];
}
}