From d02379d2df13801cde08a32fde5deec8201538d2 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 23 Jul 2009 15:59:17 +0100 Subject: bitbake: Add a cache around PACKAGES_DYNAMIC regexps to help performance a bit Signed-off-by: Richard Purdie --- bitbake-dev/lib/bb/providers.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bitbake-dev') diff --git a/bitbake-dev/lib/bb/providers.py b/bitbake-dev/lib/bb/providers.py index d0e71173d..879f1a00b 100644 --- a/bitbake-dev/lib/bb/providers.py +++ b/bitbake-dev/lib/bb/providers.py @@ -280,6 +280,8 @@ def filterProvidersRunTime(providers, item, cfgData, dataCache): return eligible, numberPreferred +regexp_cache = {} + def getRuntimeProviders(dataCache, rdepend): """ Return any providers of runtime dependency @@ -297,12 +299,17 @@ def getRuntimeProviders(dataCache, rdepend): # Only search dynamic packages if we can't find anything in other variables for pattern in dataCache.packages_dynamic: - pattern = pattern.replace('+', "\+") - try: - regexp = re.compile(pattern) - except: - bb.msg.error(bb.msg.domain.Provider, "Error parsing re expression: %s" % pattern) - raise + + if pattern in regexp_cache: + regexp = regexp_cache[pattern] + else: + pattern = pattern.replace('+', "\+") + try: + regexp = re.compile(pattern) + except: + bb.msg.error(bb.msg.domain.Provider, "Error parsing re expression: %s" % pattern) + raise + regexp_cache[pattern] = regexp if regexp.match(rdepend): rproviders += dataCache.packages_dynamic[pattern] -- cgit v1.2.3