From 3e35fe55c19a8de1f2e6bf30f827c2c1f9606488 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 10 Dec 2006 07:23:58 +0000 Subject: [PATCH] Cache results of dep_getcpv() calls. svn path=/main/trunk/; revision=5251 --- pym/portage_dep.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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): -- 2.26.2