diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-05-02 20:00:54 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-04 12:54:26 -0700 |
commit | 0bae81245b1700dd74369aeabf6c0c7c9269ee51 (patch) | |
tree | b773b442f54edbf6d9af74ad92ada56c66b5eaaa | |
parent | 8d113a9300bbdf94157529036eafd2902c810e07 (diff) | |
download | portage-0bae81245b1700dd74369aeabf6c0c7c9269ee51.tar.gz portage-0bae81245b1700dd74369aeabf6c0c7c9269ee51.tar.bz2 portage-0bae81245b1700dd74369aeabf6c0c7c9269ee51.zip |
cpv_expand: avoid old-style virtual code
This allows portageq calls to avoid loading vdb_metadata.pickle in
most cases, which greatly improves performance.
-rw-r--r-- | pym/portage/dbapi/cpv_expand.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/pym/portage/dbapi/cpv_expand.py b/pym/portage/dbapi/cpv_expand.py index c42e427d3..9ce0d3d2c 100644 --- a/pym/portage/dbapi/cpv_expand.py +++ b/pym/portage/dbapi/cpv_expand.py @@ -17,8 +17,6 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): mysplit = _pkgsplit(myslash[-1]) if settings is None: settings = globals()["settings"] - virts = settings.getvirtuals() - virts_p = settings.get_virts_p() if len(myslash)>2: # this is illegal case. mysplit=[] @@ -28,24 +26,21 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): mykey=myslash[0]+"/"+mysplit[0] else: mykey=mycpv - if mydb and virts and mykey in virts: - writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1) - if hasattr(mydb, "cp_list"): - if not mydb.cp_list(mykey, use_cache=use_cache): - writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1) - mykey_orig = mykey[:] - for vkey in virts[mykey]: + if hasattr(mydb, "cp_list") and \ + not mydb.cp_list(mykey, use_cache=use_cache): + virts = settings.getvirtuals().get(mykey) + if virts: + mykey_orig = mykey + for vkey in virts: # The virtuals file can contain a versioned atom, so # it may be necessary to remove the operator and # version from the atom before it is passed into # dbapi.cp_list(). if mydb.cp_list(vkey.cp): mykey = str(vkey) - writemsg(_("virts chosen: %s\n") % (mykey), 1) break if mykey == mykey_orig: - mykey = str(virts[mykey][0]) - writemsg(_("virts defaulted: %s\n") % (mykey), 1) + mykey = str(virts[0]) #we only perform virtual expansion if we are passed a dbapi else: #specific cpv, no category, ie. "foo-1.0" @@ -81,8 +76,9 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None): mykey=matches[0] if not mykey and not isinstance(mydb, list): - if myp in virts_p: - mykey=virts_p[myp][0] + virts_p = settings.get_virts_p().get(myp) + if virts_p: + mykey = virts_p[0] #again, we only perform virtual expansion if we have a dbapi (not a list) if not mykey: mykey="null/"+myp |