From: Jay Freeman (saurik) Date: Sat, 20 Dec 2008 10:24:53 +0000 (+0000) Subject: Improved many-theme performance. X-Git-Tag: v0.9.3900~58 X-Git-Url: https://git.saurik.com/winterboard.git/commitdiff_plain/e839c3fe1cf0fd42b6d24028bfcf3a32e9997d34 Improved many-theme performance. --- diff --git a/Library.mm b/Library.mm index 1cab91e..d317099 100644 --- a/Library.mm +++ b/Library.mm @@ -148,17 +148,29 @@ static NSMutableDictionary *Info_; static NSMutableArray *themes_; static NSString *$getTheme$(NSArray *files, bool parent = false) { + if (!parent) + if (NSString *path = [Themed_ objectForKey:files]) + return reinterpret_cast(path) == [NSNull null] ? nil : path; + if (Debug_) NSLog(@"WB:Debug: %@", [files description]); + NSString *path; + for (NSString *theme in themes_) for (NSString *file in files) { - NSString *path([NSString stringWithFormat:@"%@/%@", theme, file]); - if ([Manager_ fileExistsAtPath:path]) - return parent ? theme : path; + path = [NSString stringWithFormat:@"%@/%@", theme, file]; + if ([Manager_ fileExistsAtPath:path]) { + path = parent ? theme : path; + goto set; + } } - return nil; + path = nil; + set: + if (!parent) + [Themed_ setObject:(path == nil ? [NSNull null] : reinterpret_cast(path)) forKey:files]; + return path; } static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle, bool ui) { @@ -1065,6 +1077,7 @@ extern "C" void WBInitialize() { PathImages_ = [[NSMutableDictionary alloc] initWithCapacity:16]; Strings_ = [[NSMutableDictionary alloc] initWithCapacity:0]; Bundles_ = [[NSMutableDictionary alloc] initWithCapacity:2]; + Themed_ = [[NSMutableDictionary alloc] initWithCapacity:128]; themes_ = [[NSMutableArray alloc] initWithCapacity:8];