• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

TextMate is a graphical text editor for OS X 10.7+


Commit MetaInfo

Revision9366a1ec508bb2f45604d5212c0709f88caeca2e (tree)
Zeit2012-08-19 21:44:57
AutorAllan Odgaard <git@abet...>
CommiterAllan Odgaard

Log Message

Cache image resources

This was also done prior to commit 806cb44. I just assumed that now that we are back using the system’s named image stuff, we would benefit from their cache, but clearly we are not (especially file browser seemed sluggish because of (re)loading the file type images).

Ändern Zusammenfassung

Diff

--- a/Frameworks/OakAppKit/src/NSImage Additions.mm
+++ b/Frameworks/OakAppKit/src/NSImage Additions.mm
@@ -3,7 +3,23 @@
33 @implementation NSImage (ImageFromBundle)
44 + (NSImage*)imageNamed:(NSString*)aName inSameBundleAsClass:(id)aClass
55 {
6- return [[NSBundle bundleForClass:aClass] imageForResource:aName];
6+ if(!aName)
7+ return nil;
8+
9+ NSBundle* bundle = [NSBundle bundleForClass:aClass];
10+ NSString* name = [NSString stringWithFormat:@"%@.%@", [bundle bundleIdentifier], aName];
11+
12+ static NSMutableDictionary* cache = [NSMutableDictionary new];
13+ if(NSImage* res = [cache objectForKey:name])
14+ return res;
15+
16+ if(NSImage* image = [[NSBundle bundleForClass:aClass] imageForResource:aName])
17+ {
18+ [cache setObject:image forKey:name];
19+ return image;
20+ }
21+
22+ return nil;
723 }
824
925 // ===================================================