From 685e5f293a917ca0dd41c892f231bffaaa66910e Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 11 Jul 2009 20:23:54 +0000 Subject: Optimize USE_EXPAND -> USE code inside config.setcpv(). Thanks to Marat Radchenko for this patch from bug #276813. svn path=/main/trunk/; revision=13815 --- pym/portage/__init__.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index f31a3f835..5b74e1797 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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: -- cgit v1.2.3-1-g7c22