summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-01 06:37:55 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-01 06:37:55 +0000
commitdd012f0e9388b829d740763f094a5a9977cb9c4f (patch)
treedeaad120eb97a7869430a50142ecac95f4ecb239
parente0f037138a16a8d3d608fdd1a1fd23f06df5c6f3 (diff)
downloadportage-dd012f0e9388b829d740763f094a5a9977cb9c4f.tar.gz
portage-dd012f0e9388b829d740763f094a5a9977cb9c4f.tar.bz2
portage-dd012f0e9388b829d740763f094a5a9977cb9c4f.zip
Avoid making unnecessary copies of PackageSet._atoms by
replacing calls to self.getAtoms() with self._load(). svn path=/main/trunk/; revision=8352
-rw-r--r--pym/portage/sets/base.py19
-rw-r--r--pym/portage/sets/files.py3
2 files changed, 14 insertions, 8 deletions
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: