summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-14 16:32:19 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-14 16:32:19 +0000
commitdaac955d53fdb6c65d25ee499da4bb6d493bb344 (patch)
tree4898983d6bada97479e1ea68ecbb5ea0b6648621 /pym
parent5a65a33ccd7b201fa75e654c3123fc84a49f7e5d (diff)
downloadportage-daac955d53fdb6c65d25ee499da4bb6d493bb344.tar.gz
portage-daac955d53fdb6c65d25ee499da4bb6d493bb344.tar.bz2
portage-daac955d53fdb6c65d25ee499da4bb6d493bb344.zip
When regenerating USE_EXPAND in config.setcpv(), improve performance by
using regular expression instead of str.startswith(). svn path=/main/trunk/; revision=9890
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 5c712a472..59270ac58 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2035,8 +2035,12 @@ class config(object):
for var in use_expand:
prefix = var.lower() + "_"
prefix_len = len(prefix)
- expand_flags = set([ x[prefix_len:] for x in use \
- if x.startswith(prefix) ])
+ prefix_re = re.compile(r'^(%s)(.*)' % prefix)
+ expand_flags = set()
+ for x in use:
+ m = prefix_re.match(x)
+ if m is not None:
+ expand_flags.add(m.group(2))
var_split = self.get(var, "").split()
# Preserve the order of var_split because it can matter for things
# like LINGUAS.
@@ -2047,15 +2051,18 @@ class config(object):
var_split = [ x for x in var_split if x != "*" ]
has_iuse = set()
for x in iuse_implicit:
- if x.startswith(prefix):
- has_iuse.add(x[prefix_len:])
+ m = prefix_re.match(x)
+ if m is not None:
+ has_iuse.add(m.group(2))
if has_wildcard:
# * means to enable everything in IUSE that's not masked
if has_iuse:
for x in iuse_implicit:
- if x.startswith(prefix) and x not in self.usemask:
- suffix = x[prefix_len:]
- var_split.append(suffix)
+ if x in self.usemask:
+ continue
+ m = prefix_re.match(x)
+ if m is not None:
+ var_split.append(m.group(2))
use.add(x)
else:
# If there is a wildcard and no matching flags in IUSE then