From: Zac Medico Date: Mon, 27 Jun 2011 06:53:58 +0000 (-0700) Subject: Package.use: share identical frozenset instances X-Git-Tag: v2.2.0_alpha42~27 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7587568f3133d12ef68b633328954cb838fcaafe;p=portage.git Package.use: share identical frozenset instances --- diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 7a25638c8..20c72b481 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -392,6 +392,9 @@ class Package(Task): __slots__ = ("enabled", "_expand", "_expand_hidden", "_force", "_pkg", "_mask") + # Share identical frozenset instances when available. + _frozensets = {} + def __init__(self, pkg, use_str): self._pkg = pkg self._expand = None @@ -410,12 +413,17 @@ class Package(Task): def _init_force_mask(self): pkgsettings = self._pkg._get_pkgsettings() - self._expand = frozenset( + frozensets = self._frozensets + s = frozenset( pkgsettings.get("USE_EXPAND", "").lower().split()) - self._expand_hidden = frozenset( + self._expand = frozensets.setdefault(s, s) + s = frozenset( pkgsettings.get("USE_EXPAND_HIDDEN", "").lower().split()) - self._force = pkgsettings.useforce - self._mask = pkgsettings.usemask + self._expand_hidden = frozensets.setdefault(s, s) + s = pkgsettings.useforce + self._force = frozensets.setdefault(s, s) + s = pkgsettings.usemask + self._mask = frozensets.setdefault(s, s) @property def expand(self):