summaryrefslogtreecommitdiffstats
path: root/util/local_database
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-20 20:33:11 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-23 07:08:28 +0000
commit9c97e5c40e48c463cebf3c72f3893fcda5eac616 (patch)
tree37cc5b408abc1e9916e5986416dbe80113926e1d /util/local_database
parent7ae4ffa0e0f7bdec7b400f1df605cd6102749482 (diff)
[locale database utility] Optimize by caching the locale lookup chain
Change-Id: I1b95b3365337753ca0ab782091fa61870b77b051 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'util/local_database')
-rw-r--r--util/local_database/xpathlite.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py
index 112dc14ce8..ecf1dad444 100644
--- a/util/local_database/xpathlite.py
+++ b/util/local_database/xpathlite.py
@@ -191,8 +191,12 @@ def findAlias(file):
return False
return alias_elt.attributes['source'].nodeValue
+lookup_chain_cache = {}
parent_locales = {}
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
if not parent_locales:
for ns in findTagsInFile(dirname + "/../supplemental/supplementalData.xml", "parentLocales"):
@@ -218,7 +222,10 @@ def _fixedLookupChain(dirname, name):
items = items[:i+1]
else:
items = items[:i+1] + _fixedLookupChain(dirname, parent_locale)
+ lookup_chain_cache[name] = items
return items
+
+ lookup_chain_cache[name] = items
return items
def _findEntry(base, path, draft=None, attribute=None):