Optimize display_preserved_libs() by using a single getFileOwnerMap() to look
authorZac Medico <zmedico@gentoo.org>
Thu, 2 Oct 2008 03:58:49 +0000 (03:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 2 Oct 2008 03:58:49 +0000 (03:58 -0000)
up all the files.

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

pym/_emerge/__init__.py

index 366568c516f1443610e3fa0bf8dea879b2dc7a83..0e7f241fd78877fac65948dd3cba5adafdeca160 100644 (file)
@@ -10907,13 +10907,27 @@ def display_preserved_libs(vardbapi):
                print colorize("WARN", "!!!") + " existing preserved libs:"
                plibdata = vardbapi.plib_registry.getPreservedLibs()
                linkmap = vardbapi.linkmap
+
+               consumer_map = {}
+               search_for_owners = set()
                for cpv in plibdata:
-                       print colorize("WARN", ">>>") + " package: %s" % cpv
                        for f in plibdata[cpv]:
-                               print colorize("WARN", " * ") + " - %s" % f
+                               if f in consumer_map:
+                                       continue
                                consumers = list(linkmap.findConsumers(f))
                                consumers.sort()
-                               owners = vardbapi._owners.getFileOwnerMap(consumers[:MAX_DISPLAY+2])
+                               consumer_map[f] = consumers
+                               search_for_owners.update(consumers[:MAX_DISPLAY+1])
+
+               all_owners = vardbapi._owners.getFileOwnerMap(search_for_owners)
+
+               for cpv in plibdata:
+                       print colorize("WARN", ">>>") + " package: %s" % cpv
+                       for f in plibdata[cpv]:
+                               print colorize("WARN", " * ") + " - %s" % f
+                               consumers = consumer_map[f]
+                               owners = dict((c, all_owners[c])
+                                       for c in consumers[:MAX_DISPLAY+1])
                                for c in consumers[:MAX_DISPLAY]:
                                        print colorize("WARN", " * ") + "     used by %s (%s)" % (c, ", ".join([x.mycpv for x in owners[c]]))
                                if len(consumers) == MAX_DISPLAY + 1: