diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-07-21 03:51:28 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-07-21 03:51:28 +0000 |
commit | 7ace238bb48e4e1f303879e9f4903a4cc95039c9 (patch) | |
tree | 64ad8d5383fa8a8462d3b95bf47ac6df7bd621b9 | |
parent | 99310c0af721e08c2ab5f2d3c9c02ed3691368cb (diff) | |
download | portage-7ace238bb48e4e1f303879e9f4903a4cc95039c9.tar.gz portage-7ace238bb48e4e1f303879e9f4903a4cc95039c9.tar.bz2 portage-7ace238bb48e4e1f303879e9f4903a4cc95039c9.zip |
Optimize PackageSet._updateAtomMap() for the case where one or more atoms are added and none are removed.
svn path=/main/trunk/; revision=7329
-rw-r--r-- | pym/portage/sets/__init__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pym/portage/sets/__init__.py b/pym/portage/sets/__init__.py index 29dc60c07..3e1fbdb2e 100644 --- a/pym/portage/sets/__init__.py +++ b/pym/portage/sets/__init__.py @@ -77,9 +77,12 @@ class PackageSet(object): else: return "" - def _updateAtomMap(self): - self._atommap.clear() - for a in self._atoms: + def _updateAtomMap(self, atoms=None): + """Update self._atommap for specific atoms or all atoms.""" + if not atoms: + self._atommap.clear() + atoms = self._atoms + for a in atoms: cp = dep_getkey(a) self._atommap.setdefault(cp, set()) self._atommap[cp].add(a) @@ -118,7 +121,7 @@ class EditablePackageSet(PackageSet): def update(self, atoms): self.getAtoms() self._atoms.update(atoms) - self._updateAtomMap() + self._updateAtomMap(atoms=atoms) self.write() def add(self, atom): |