From: Zac Medico Date: Mon, 6 Nov 2006 21:21:21 +0000 (-0000) Subject: Minimize getvirtuals() calls and dict lookups inside dep_virtual(). X-Git-Tag: v2.1.2~497 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b46477f5c9ae4609741841aed7660f320b8344db;p=portage.git Minimize getvirtuals() calls and dict lookups inside dep_virtual(). svn path=/main/trunk/; revision=4966 --- diff --git a/pym/portage.py b/pym/portage.py index edb13146d..e438adea8 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -3451,23 +3451,24 @@ def getCPFromCPV(mycpv): def dep_virtual(mysplit, mysettings): "Does virtual dependency conversion" newsplit=[] + myvirtuals = mysettings.getvirtuals() for x in mysplit: if type(x)==types.ListType: newsplit.append(dep_virtual(x, mysettings)) else: mykey=dep_getkey(x) - myvirtuals = mysettings.getvirtuals() - if myvirtuals.has_key(mykey): - if len(myvirtuals[mykey]) == 1: - a = string.replace(x, mykey, myvirtuals[mykey][0]) + mychoices = myvirtuals.get(mykey, None) + if mychoices: + if len(mychoices) == 1: + a = x.replace(mykey, mychoices[0]) else: if x[0]=="!": # blocker needs "and" not "or(||)". a=[] else: a=['||'] - for y in myvirtuals[mykey]: - a.append(string.replace(x, mykey, y)) + for y in mychoices: + a.append(x.replace(mykey, y)) newsplit.append(a) else: newsplit.append(x)