summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-11-07 14:45:59 -0800
committerZac Medico <zmedico@gentoo.org>2010-11-07 14:45:59 -0800
commitac5f9017bb621d1deaab932204362bf918ffd088 (patch)
tree59ae6bffe12b46bf0c5d22b4852f809f34a3e3ef
parentc889e072b72774beaaf8783017e3674df0895d0d (diff)
downloadportage-ac5f9017bb621d1deaab932204362bf918ffd088.tar.gz
portage-ac5f9017bb621d1deaab932204362bf918ffd088.tar.bz2
portage-ac5f9017bb621d1deaab932204362bf918ffd088.zip
Move _get_use* calls out of loops.
-rw-r--r--pym/portage/dep/__init__.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 7ff54f6f7..ab7c2a22f 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -301,6 +301,8 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
if matchall and matchnone:
raise ValueError("portage.dep.use_reduce: 'matchall' and 'matchnone' are mutually exclusive")
+ useflag_re = _get_useflag_re(eapi)
+
def is_active(conditional):
"""
Decides if a given use conditional is active.
@@ -320,7 +322,7 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
e = InvalidData(msg, category='IUSE.missing')
raise InvalidDependString(msg, errors=(e,))
else:
- if _get_useflag_re(eapi).match(flag) is None:
+ if useflag_re.match(flag) is None:
raise InvalidDependString(
_("invalid use flag '%s' in conditional '%s'") % (flag, conditional))
@@ -705,9 +707,10 @@ class _use_dep(object):
no_default = set()
conditional = {}
+ usedep_re = _get_usedep_re(self.eapi)
for x in use:
- m = _get_usedep_re(self.eapi).match(x)
+ m = usedep_re.match(x)
if m is None:
raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
@@ -807,9 +810,10 @@ class _use_dep(object):
disabled_flags = set(self.disabled)
tokens = []
+ usedep_re = _get_usedep_re(self.eapi)
for x in self.tokens:
- m = _get_usedep_re(self.eapi).match(x)
+ m = usedep_re.match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")
@@ -864,9 +868,10 @@ class _use_dep(object):
def validate_flag(flag):
return is_valid_flag(flag) or flag in all_defaults
+ usedep_re = _get_usedep_re(self.eapi)
for x in self.tokens:
- m = _get_usedep_re(self.eapi).match(x)
+ m = usedep_re.match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")
@@ -975,9 +980,10 @@ class _use_dep(object):
missing_disabled = self.missing_disabled
tokens = []
+ usedep_re = _get_usedep_re(self.eapi)
for x in self.tokens:
- m = _get_usedep_re(self.eapi).match(x)
+ m = usedep_re.match(x)
operator = m.group("prefix") + m.group("suffix")
flag = m.group("flag")