From: Zac Medico Date: Sun, 10 Dec 2006 07:23:58 +0000 (-0000) Subject: Cache results of dep_getcpv() calls. X-Git-Tag: v2.1.2~333 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3e35fe55c19a8de1f2e6bf30f827c2c1f9606488;p=portage.git Cache results of dep_getcpv() calls. svn path=/main/trunk/; revision=5251 --- 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):