summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-28 20:29:04 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-28 20:29:04 +0000
commit9e9c8c412d7c8fa5137b530af11f1019c7ceab09 (patch)
tree8d4875ebea70446ed79c4d34e7fe657000c28324
parent0165f306e1d5b9c9ad2688c1f30b0f37c09dba87 (diff)
downloadportage-9e9c8c412d7c8fa5137b530af11f1019c7ceab09.tar.gz
portage-9e9c8c412d7c8fa5137b530af11f1019c7ceab09.tar.bz2
portage-9e9c8c412d7c8fa5137b530af11f1019c7ceab09.zip
Add a Package.pv_split attibute to optimize version comparison
operators. svn path=/main/trunk/; revision=10026
-rw-r--r--pym/_emerge/__init__.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 2309eb4d8..0249808ea 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1265,12 +1265,13 @@ class Blocker(Task):
class Package(Task):
__slots__ = ("built", "cpv", "depth",
"installed", "metadata", "root", "onlydeps", "type_name",
- "cp", "cpv_slot", "slot_atom")
+ "cp", "cpv_slot", "pv_split", "slot_atom")
def __init__(self, **kwargs):
Task.__init__(self, **kwargs)
self.cp = portage.cpv_getkey(self.cpv)
self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"])
self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"])
+ self.pv_split = portage.catpkgsplit(self.cpv)[1:]
def _get_hash_key(self):
hash_key = getattr(self, "_hash_key", None)
@@ -1283,38 +1284,30 @@ class Package(Task):
return self._hash_key
def __lt__(self, other):
- other_split = portage.catpkgsplit(other.cpv)
- self_split = portage.catpkgsplit(self.cpv)
- if other_split[:2] != self_split[:2]:
+ if other.cp != self.cp:
return False
- if portage.pkgcmp(self_split[1:], other_split[1:]) < 0:
+ if portage.pkgcmp(self.pv_split, other.pv_split) < 0:
return True
return False
def __le__(self, other):
- other_split = portage.catpkgsplit(other.cpv)
- self_split = portage.catpkgsplit(self.cpv)
- if other_split[:2] != self_split[:2]:
+ if other.cp != self.cp:
return False
- if portage.pkgcmp(self_split[1:], other_split[1:]) <= 0:
+ if portage.pkgcmp(self.pv_split, other.pv_split) <= 0:
return True
return False
def __gt__(self, other):
- other_split = portage.catpkgsplit(other.cpv)
- self_split = portage.catpkgsplit(self.cpv)
- if other_split[:2] != self_split[:2]:
+ if other.cp != self.cp:
return False
- if portage.pkgcmp(self_split[1:], other_split[1:]) > 0:
+ if portage.pkgcmp(self.pv_split, other.pv_split) > 0:
return True
return False
def __ge__(self, other):
- other_split = portage.catpkgsplit(other.cpv)
- self_split = portage.catpkgsplit(self.cpv)
- if other_split[:2] != self_split[:2]:
+ if other.cp != self.cp:
return False
- if portage.pkgcmp(self_split[1:], other_split[1:]) >= 0:
+ if portage.pkgcmp(self.pv_split, other.pv_split) >= 0:
return True
return False