Make LibraryConsumerSet.mapPathsToAtoms() use the contents index for more
authorZac Medico <zmedico@gentoo.org>
Sat, 21 Jun 2008 14:58:13 +0000 (14:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 21 Jun 2008 14:58:13 +0000 (14:58 -0000)
efficient owner lookups.

svn path=/main/trunk/; revision=10754

pym/portage/sets/libs.py

index 774ef5ac4b11a6c7efc5dfa13f251f6db5840045..e8d6a6107b513dd5dcfe8cc3adb919d8c1a2e490 100644 (file)
@@ -4,10 +4,7 @@
 
 from portage.sets.base import PackageSet
 from portage.sets import get_boolean
-from portage.dbapi.vartree import dblink
-from portage.versions import catsplit, catpkgsplit
-
-import os
+from portage.versions import catpkgsplit
 
 class LibraryConsumerSet(PackageSet):
        _operations = ["merge", "unmerge"]
@@ -19,17 +16,13 @@ class LibraryConsumerSet(PackageSet):
 
        def mapPathsToAtoms(self, paths):
                rValue = set()
-               for cpv in self.dbapi.cpv_all():
-                       mysplit = catsplit(cpv)
-                       link = dblink(mysplit[0], mysplit[1], myroot=self.dbapi.root, \
-                                       mysettings=self.dbapi.settings, treetype='vartree', \
-                                       vartree=self.dbapi.vartree)
-                       if paths.intersection(link.getcontents()):
-                               cat, pn = catpkgsplit(cpv)[:2]
-                               slot = self.dbapi.aux_get(cpv, ["SLOT"])[0]
-                               rValue.add("%s/%s:%s" % (cat, pn, slot))
+               root_len = len(self.dbapi.root)
+               for link, relative_p in self.dbapi._owners.iter_owners(
+                       p[root_len:] for p in paths):
+                       cat, pn = catpkgsplit(link.mycpv)[:2]
+                       slot = self.dbapi.aux_get(link.mycpv, ["SLOT"])[0]
+                       rValue.add("%s/%s:%s" % (cat, pn, slot))
                return rValue
-       
 
 class PreservedLibraryConsumerSet(LibraryConsumerSet):
        def load(self):