summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/__init__.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-06 21:56:27 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-06 21:56:27 +0000
commit317ec856890cfca41c4655dd638e5804ce50b95c (patch)
treee0b3f84fcb07ccff87da8c141c8e5f304ffd16c9 /pym/portage/dbapi/__init__.py
parent1d13ae1ea7d44d6ecfdd401be4c4d867b61ff632 (diff)
downloadportage-317ec856890cfca41c4655dd638e5804ce50b95c.tar.gz
portage-317ec856890cfca41c4655dd638e5804ce50b95c.tar.bz2
portage-317ec856890cfca41c4655dd638e5804ce50b95c.zip
Optimize dbapi._iter_match_use() so that it shares a single compiled regex
for all implicit iuse checks. This avoids lots of expensibe re.compile() calls. Thanks to Marat Radchenko <slonopotamusorama@gmail.com> for the initial patch. svn path=/main/trunk/; revision=13801
Diffstat (limited to 'pym/portage/dbapi/__init__.py')
-rw-r--r--pym/portage/dbapi/__init__.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index abd6cc870..08b7a3b9b 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -23,7 +23,7 @@ class dbapi(object):
_category_re = re.compile(r'^\w[-.+\w]*$')
_pkg_dir_name_re = re.compile(r'^\w[-+\w]*$')
_categories = None
- _iuse_implicit = None
+ _iuse_implicit_re = None
_use_mutable = False
_known_keys = frozenset(x for x in auxdbkeys
if not x.startswith("UNUSED_0"))
@@ -149,20 +149,20 @@ class dbapi(object):
1) Check for required IUSE intersection (need implicit IUSE here).
2) Check enabled/disabled flag states.
"""
- if self._iuse_implicit is None:
- self._iuse_implicit = self.settings._get_implicit_iuse()
+ if self._iuse_implicit_re is None:
+ self._iuse_implicit_re = re.compile("^(%s)$" % \
+ "|".join(self.settings._get_implicit_iuse()))
+ iuse_implicit_re = self._iuse_implicit_re
for cpv in cpv_iter:
try:
iuse, slot, use = self.aux_get(cpv, ["IUSE", "SLOT", "USE"])
except KeyError:
continue
use = use.split()
- iuse = self._iuse_implicit.union(
- re.escape(x.lstrip("+-")) for x in iuse.split())
- iuse_re = re.compile("^(%s)$" % "|".join(iuse))
+ iuse = frozenset(x.lstrip('+-') for x in iuse.split())
missing_iuse = False
for x in atom.use.required:
- if iuse_re.match(x) is None:
+ if x not in iuse and iuse_implicit_re.match(x) is None:
missing_iuse = True
break
if missing_iuse: