Optimize PackageSet._updateAtomMap() for the case where one or more atoms are added...
authorZac Medico <zmedico@gentoo.org>
Sat, 21 Jul 2007 03:51:28 +0000 (03:51 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 Jul 2007 03:51:28 +0000 (03:51 -0000)
svn path=/main/trunk/; revision=7329

pym/portage/sets/__init__.py

index 29dc60c07670fe91ea37aaf972ec288fcf52a3ea..3e1fbdb2e3ed65d78adb1351ff2acd47034f2eb0 100644 (file)
@@ -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):