From: Zac Medico Date: Thu, 1 Nov 2007 06:37:55 +0000 (-0000) Subject: Avoid making unnecessary copies of PackageSet._atoms by X-Git-Tag: v2.2_pre1~473 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dd012f0e9388b829d740763f094a5a9977cb9c4f;p=portage.git Avoid making unnecessary copies of PackageSet._atoms by replacing calls to self.getAtoms() with self._load(). svn path=/main/trunk/; revision=8352 --- diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py index 8e5863cba..85f2e410b 100644 --- a/pym/portage/sets/base.py +++ b/pym/portage/sets/base.py @@ -30,9 +30,12 @@ class PackageSet(object): return atom in self._atoms or atom in self._nonatoms def __iter__(self): - for x in self.getAtoms(): + self._load() + for x in self._atoms: yield x - + for x in self._nonatoms: + yield x + def supportsOperation(self, op): if not op in OPERATIONS: raise ValueError(op) @@ -72,7 +75,8 @@ class PackageSet(object): raise NotImplementedError() def containsCPV(self, cpv): - for a in self.getAtoms(): + self._load() + for a in self._atoms: if match_from_list(a, [cpv]): return True return False @@ -101,7 +105,7 @@ class PackageSet(object): if an error occurs while parsing PROVIDE.""" cpv_slot = "%s:%s" % (cpv, metadata["SLOT"]) cp = dep_getkey(cpv) - self.getAtoms() # make sure the atoms are loaded + self._load() # make sure the atoms are loaded atoms = self._atommap.get(cp) if atoms: best_match = best_match_to_list(cpv_slot, atoms) @@ -125,7 +129,7 @@ class PackageSet(object): class EditablePackageSet(PackageSet): def update(self, atoms): - self.getAtoms() + self._load() modified = False normal_atoms = [] for a in atoms: @@ -149,13 +153,14 @@ class EditablePackageSet(PackageSet): self.write() def remove(self, atom): - self.getAtoms() + self._load() self._atoms.discard(atom) self._updateAtomMap() self.write() def removePackageAtoms(self, cp): - for a in list(self.getAtoms()): + self._load() + for a in list(self._atoms): if dep_getkey(a) == cp: self.remove(a) self.write() diff --git a/pym/portage/sets/files.py b/pym/portage/sets/files.py index 010966c2a..5b6fe8838 100644 --- a/pym/portage/sets/files.py +++ b/pym/portage/sets/files.py @@ -150,7 +150,8 @@ class WorldSet(StaticFileSet): def cleanPackage(self, vardb, cpv): self.lock() - worldlist = list(self.getAtoms()) # loads latest from disk + self._load() # loads latest from disk + worldlist = list(self._atoms) mykey = cpv_getkey(cpv) newworldlist = [] for x in worldlist: