summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-12 23:04:43 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-12 23:04:43 +0000
commit40ecc8b564c77a089f1276987d038bb483638fb1 (patch)
tree9debac6fdedb3ce44d6d940f31858a5e4feb5511
parent7b8f73f40fd6372947532c60f2a9d5674a57ae9e (diff)
downloadportage-40ecc8b564c77a089f1276987d038bb483638fb1.tar.gz
portage-40ecc8b564c77a089f1276987d038bb483638fb1.tar.bz2
portage-40ecc8b564c77a089f1276987d038bb483638fb1.zip
Optimize USE_EXPAND -> USE code inside config.setcpv(). Thanks to
Marat Radchenko <slonopotamusorama@gmail.com> for the initial patch from bug #276813. svn path=/main/trunk/; revision=13823
-rw-r--r--pym/portage/__init__.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 4dc62fa5a..d78491c4d 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2386,27 +2386,37 @@ class config(object):
# Use the calculated USE flags to regenerate the USE_EXPAND flags so
# that they are consistent. For optimal performance, use slice
# comparison instead of startswith().
- use_expand_split = set(self.get("USE_EXPAND", "").split())
+ use_expand_split = set(x.lower() for \
+ x in self.get('USE_EXPAND', '').split())
lazy_use_expand = self._lazy_use_expand(use, self.usemask,
iuse_implicit, use_expand_split, self._use_expand_dict)
- for key in use_expand_split:
- prefix = key.lower() + '_'
- prefix_len = len(prefix)
- use_expand_iuse = set( x for x in iuse_implicit \
- if x[:prefix_len] == prefix )
- # * means to enable everything in IUSE that's not masked
- if use_expand_iuse:
- if prefix + '*' in use:
- use.update( use_expand_iuse.difference(usemask) )
- self.configdict['env'].addLazySingleton(
- key, lazy_use_expand.__getitem__, key)
- else:
- # It's not in IUSE, so just allow the variable content
- # to pass through if it is defined somewhere. This
- # allows packages that support LINGUAS but don't
- # declare it in IUSE to use the variable outside of the
- # USE_EXPAND context.
- pass
+
+ use_expand_iuses = {}
+ for x in iuse_implicit:
+ x_split = x.split('_')
+ if len(x_split) == 1:
+ continue
+ for i in xrange(len(x_split) - 1):
+ k = '_'.join(x_split[:i+1])
+ if k in use_expand_split:
+ v = use_expand_iuses.get(k)
+ if v is None:
+ v = set()
+ use_expand_iuses[k] = v
+ v.add(x)
+ break
+
+ # If it's not in IUSE, variable content is allowed
+ # to pass through if it is defined somewhere. This
+ # allows packages that support LINGUAS but don't
+ # declare it in IUSE to use the variable outside of the
+ # USE_EXPAND context.
+ for k, use_expand_iuse in use_expand_iuses.iteritems():
+ if k + '_*' in use:
+ use.update( x for x in use_expand_iuse if x not in usemask )
+ k = k.upper()
+ self.configdict['env'].addLazySingleton(k,
+ lazy_use_expand.__getitem__, k)
# Filtered for the ebuild environment. Store this in a separate
# attribute since we still want to be able to see global USE