Cache the results of match_from_list() calls.
authorZac Medico <zmedico@gentoo.org>
Sun, 10 Dec 2006 07:09:46 +0000 (07:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 10 Dec 2006 07:09:46 +0000 (07:09 -0000)
svn path=/main/trunk/; revision=5250

pym/portage_dep.py

index f592d209f5b2daf754c341d57af63be84e3ec672..c0f6467e55038806f1442e70f4c181954544ff48 100644 (file)
@@ -478,6 +478,8 @@ def best_match_to_list(mypkg, mylist):
                        bestm  = x
        return bestm
 
+_match_from_list_cache = {}
+
 def match_from_list(mydep, candidate_list):
        """
        Searches list for entries that matches the package.
@@ -490,6 +492,11 @@ def match_from_list(mydep, candidate_list):
        @return: A list of package atoms that match the given package atom
        """
 
+       global _match_from_list_cache
+       mylist = _match_from_list_cache.get((mydep, tuple(candidate_list)), None)
+       if mylist is not None:
+               return mylist[:]
+
        from portage_util import writemsg
        if mydep[0] == "!":
                mydep = mydep[1:]
@@ -585,4 +592,5 @@ def match_from_list(mydep, candidate_list):
        else:
                raise KeyError("Unknown operator: %s" % mydep)
 
+       _match_from_list_cache[(mydep, tuple(candidate_list))] = mylist
        return mylist