Further optimized things by caching the parsed strings dictionary directly

pull/5/head
Wolfgang Sourdeau 2012-10-18 13:37:42 -04:00
parent 1e84bccf42
commit 479772a73f
1 changed files with 9 additions and 17 deletions

View File

@ -99,7 +99,7 @@
NSDictionary *strings;
SOGoUserDefaults *ud;
static NSMutableDictionary *bundlesCache = nil;
NSMutableDictionary *languagesCache, *stringsCache;
NSMutableDictionary *languagesCache;
if (!bundlesCache)
bundlesCache = [NSMutableDictionary new];
@ -119,16 +119,8 @@
ud = [[context activeUser] userDefaults];
userLanguage = [ud language];
stringsCache = [languagesCache objectForKey: userLanguage];
if (!stringsCache)
{
stringsCache = [NSMutableDictionary new];
[bundlesCache setObject: stringsCache forKey: userLanguage];
[stringsCache release];
}
label = [stringsCache objectForKey: key];
if (!label)
strings = [languagesCache objectForKey: userLanguage];
if (!strings)
{
paths = [bundle pathsForResourcesOfType: @"strings"
inDirectory: [NSString stringWithFormat: @"%@.lproj",
@ -138,14 +130,14 @@
{
strings = [NSDictionary
dictionaryFromStringsFile: [paths objectAtIndex: 0]];
label = [strings objectForKey: key];
if (!label)
label = key;
if (strings)
[languagesCache setObject: strings forKey: userLanguage];
}
else
label = key;
[stringsCache setObject: label forKey: key];
}
label = [strings objectForKey: key];
if (!label)
label = key;
return label;
}