Optimize USE_EXPAND -> USE code inside config.setcpv(). Thanks to
authorZac Medico <zmedico@gentoo.org>
Sat, 11 Jul 2009 20:23:54 +0000 (20:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 11 Jul 2009 20:23:54 +0000 (20:23 -0000)
Marat Radchenko <slonopotamusorama@gmail.com> for this patch from
bug #276813.

svn path=/main/trunk/; revision=13815

pym/portage/__init__.py

index f31a3f8352ff5fbe90606f6cd35068e01c2d3f1c..5b74e1797c3cb6fb495d446bc49444ea3a527963 100644 (file)
@@ -2387,25 +2387,18 @@ 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 = self.get("USE_EXPAND", "").split()
+               use_expand_split = set(self.get("USE_EXPAND", "").split())
                lazy_use_expand = self._lazy_use_expand(use, self.usemask,
                        iuse_implicit, use_expand_split, self._use_expand_dict)
-               use_expand_iuse = set()
                for key in use_expand_split:
                        prefix = key.lower() + '_'
                        prefix_len = len(prefix)
-                       expand_flags = set( x[prefix_len:] for x in use \
+                       use_expand_iuse = set( x for x in iuse_implicit \
                                if x[:prefix_len] == prefix )
-                       use_expand_iuse.clear()
-                       for x in iuse_implicit:
-                               if x[:prefix_len] == prefix:
-                                       use_expand_iuse.add(x)
                        # * means to enable everything in IUSE that's not masked
-                       if use_expand_iuse and '*' in expand_flags:
-                               for x in use_expand_iuse:
-                                       if x not in usemask:
-                                               use.add(x)
                        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: