summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-10 03:59:37 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-10 03:59:37 +0000
commitc4a095aee57f80695b7637385623f5fdcc8d44dc (patch)
tree4e7aa414028b9771cca659e64106185b88abeb3a
parentddec8714cff06ebe933ec5ff8b9469a736d6c306 (diff)
downloadportage-c4a095aee57f80695b7637385623f5fdcc8d44dc.tar.gz
portage-c4a095aee57f80695b7637385623f5fdcc8d44dc.tar.bz2
portage-c4a095aee57f80695b7637385623f5fdcc8d44dc.zip
Optimize dbapi._cpv_sort_ascending() by calling vercmp directly instead of
calling pkgcmp. svn path=/main/trunk/; revision=12815
-rw-r--r--pym/portage/dbapi/__init__.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index 6bea1e5d3..9956d0999 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -13,7 +13,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.locks:unlockfile',
'portage.output:colorize',
'portage.util:cmp_sort_key,writemsg',
- 'portage.versions:catpkgsplit,pkgcmp',
+ 'portage.versions:catpkgsplit,vercmp',
)
from portage import auxdbkeys, dep_expand
@@ -60,14 +60,12 @@ class dbapi(object):
# If the cpv includes explicit -r0, it has to be preserved
# for consistency in findname and aux_get calls, so use a
# dict to map strings back to their original values.
- str_map = {}
- for i, cpv in enumerate(cpv_list):
- mysplit = tuple(catpkgsplit(cpv)[1:])
- str_map[mysplit] = cpv
- cpv_list[i] = mysplit
- cpv_list.sort(key=cmp_sort_key(pkgcmp))
- for i, mysplit in enumerate(cpv_list):
- cpv_list[i] = str_map[mysplit]
+ ver_map = {}
+ for cpv in cpv_list:
+ ver_map[cpv] = '-'.join(catpkgsplit(cpv)[2:])
+ def cmp_cpv(cpv1, cpv2):
+ return vercmp(ver_map[cpv1], ver_map[cpv2])
+ cpv_list.sort(key=cmp_sort_key(cmp_cpv))
def cpv_all(self):
"""Return all CPVs in the db