From 479772a73f82456626d59337a8173732ba9844ed Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 18 Oct 2012 13:37:42 -0400 Subject: [PATCH] Further optimized things by caching the parsed strings dictionary directly --- UI/Common/WODirectAction+SOGo.m | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/UI/Common/WODirectAction+SOGo.m b/UI/Common/WODirectAction+SOGo.m index 4a50c768a..aea218ef6 100644 --- a/UI/Common/WODirectAction+SOGo.m +++ b/UI/Common/WODirectAction+SOGo.m @@ -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; }