From 70d7c7bfb20dec3fa66b0e6c1d9729ac87cab577 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 13 Dec 2011 09:00:21 -0800 Subject: config: use frozenset for _constant_keys lookup --- pym/portage/package/ebuild/config.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'pym') diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 9a8486c39..f6166c65b 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -122,6 +122,9 @@ class config(object): virtuals ...etc you look in here. """ + _constant_keys = frozenset(['PORTAGE_BIN_PATH', 'PORTAGE_GID', + 'PORTAGE_PYM_PATH']) + _setcpv_aux_keys = ('DEFINED_PHASES', 'DEPEND', 'EAPI', 'INHERITED', 'IUSE', 'REQUIRED_USE', 'KEYWORDS', 'LICENSE', 'PDEPEND', 'PROPERTIES', 'PROVIDE', 'RDEPEND', 'SLOT', @@ -2126,14 +2129,16 @@ class config(object): def _getitem(self, mykey): - # These ones point to temporary values when - # portage plans to update itself. - if mykey == "PORTAGE_BIN_PATH": - return portage._bin_path - elif mykey == "PORTAGE_PYM_PATH": - return portage._pym_path - elif mykey == "PORTAGE_GID": - return _unicode_decode(str(portage_gid)) + if mykey in self._constant_keys: + # These two point to temporary values when + # portage plans to update itself. + if mykey == "PORTAGE_BIN_PATH": + return portage._bin_path + elif mykey == "PORTAGE_PYM_PATH": + return portage._pym_path + + elif mykey == "PORTAGE_GID": + return _unicode_decode(str(portage_gid)) for d in self.lookuplist: try: @@ -2186,9 +2191,7 @@ class config(object): def __iter__(self): keys = set() - keys.add("PORTAGE_BIN_PATH") - keys.add("PORTAGE_PYM_PATH") - keys.add("PORTAGE_GID") + keys.update(self._constant_keys) for d in self.lookuplist: keys.update(d) return iter(keys) -- cgit v1.2.3-1-g7c22