summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-12-10 07:23:58 +0000
committerZac Medico <zmedico@gentoo.org>2006-12-10 07:23:58 +0000
commit3e35fe55c19a8de1f2e6bf30f827c2c1f9606488 (patch)
treef1322a890848e10ae9d70694d8ee6fdb75aa798d
parent4fa940a3db4ad6b97eab325a071a2f27a4b507fd (diff)
downloadportage-3e35fe55c19a8de1f2e6bf30f827c2c1f9606488.tar.gz
portage-3e35fe55c19a8de1f2e6bf30f827c2c1f9606488.tar.bz2
portage-3e35fe55c19a8de1f2e6bf30f827c2c1f9606488.zip
Cache results of dep_getcpv() calls.
svn path=/main/trunk/; revision=5251
-rw-r--r--pym/portage_dep.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pym/portage_dep.py b/pym/portage_dep.py
index c0f6467e5..d665507a6 100644
--- a/pym/portage_dep.py
+++ b/pym/portage_dep.py
@@ -257,6 +257,8 @@ def get_operator(mydep):
return operator
+_dep_getcpv_cache = {}
+
def dep_getcpv(mydep):
"""
Return the category-package-version with any operators/slot specifications stripped off
@@ -270,6 +272,11 @@ def dep_getcpv(mydep):
@rtype: String
@return: The depstring with the operator removed
"""
+ global _dep_getcpv_cache
+ retval = _dep_getcpv_cache.get(mydep, None)
+ if retval is not None:
+ return retval
+ mydep_orig = mydep
if mydep and mydep[0] == "*":
mydep = mydep[1:]
if mydep and mydep[-1] == "*":
@@ -282,7 +289,8 @@ def dep_getcpv(mydep):
mydep = mydep[1:]
colon = mydep.rfind(":")
if colon != -1:
- return mydep[:colon]
+ mydep = mydep[:colon]
+ _dep_getcpv_cache[mydep_orig] = mydep
return mydep
def dep_getslot(mydep):