From: Zac Medico Date: Thu, 2 Oct 2008 03:58:49 +0000 (-0000) Subject: Optimize display_preserved_libs() by using a single getFileOwnerMap() to look X-Git-Tag: v2.2_rc12~44 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0766aed141800ca2bdb4f764aace49d8e63e8f0d;p=portage.git Optimize display_preserved_libs() by using a single getFileOwnerMap() to look up all the files. svn path=/main/trunk/; revision=11608 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 366568c51..0e7f241fd 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -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: