From: Zac Medico Date: Sat, 21 Jul 2007 03:51:28 +0000 (-0000) Subject: Optimize PackageSet._updateAtomMap() for the case where one or more atoms are added... X-Git-Tag: v2.2_pre1~981 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7ace238bb48e4e1f303879e9f4903a4cc95039c9;p=portage.git Optimize PackageSet._updateAtomMap() for the case where one or more atoms are added and none are removed. svn path=/main/trunk/; revision=7329 --- 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):