[locale database utility] Optimize by caching the locale lookup chain
Change-Id: I1b95b3365337753ca0ab782091fa61870b77b051 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
7ae4ffa0e0
commit
9c97e5c40e
@ -191,8 +191,12 @@ def findAlias(file):
|
|||||||
return False
|
return False
|
||||||
return alias_elt.attributes['source'].nodeValue
|
return alias_elt.attributes['source'].nodeValue
|
||||||
|
|
||||||
|
lookup_chain_cache = {}
|
||||||
parent_locales = {}
|
parent_locales = {}
|
||||||
def _fixedLookupChain(dirname, name):
|
def _fixedLookupChain(dirname, name):
|
||||||
|
if lookup_chain_cache.has_key(name):
|
||||||
|
return lookup_chain_cache[name]
|
||||||
|
|
||||||
# see http://www.unicode.org/reports/tr35/#Parent_Locales
|
# see http://www.unicode.org/reports/tr35/#Parent_Locales
|
||||||
if not parent_locales:
|
if not parent_locales:
|
||||||
for ns in findTagsInFile(dirname + "/../supplemental/supplementalData.xml", "parentLocales"):
|
for ns in findTagsInFile(dirname + "/../supplemental/supplementalData.xml", "parentLocales"):
|
||||||
@ -218,7 +222,10 @@ def _fixedLookupChain(dirname, name):
|
|||||||
items = items[:i+1]
|
items = items[:i+1]
|
||||||
else:
|
else:
|
||||||
items = items[:i+1] + _fixedLookupChain(dirname, parent_locale)
|
items = items[:i+1] + _fixedLookupChain(dirname, parent_locale)
|
||||||
|
lookup_chain_cache[name] = items
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
lookup_chain_cache[name] = items
|
||||||
return items
|
return items
|
||||||
|
|
||||||
def _findEntry(base, path, draft=None, attribute=None):
|
def _findEntry(base, path, draft=None, attribute=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user