For bug #179206, improve efficiency by using a containment test instead of str.count...
authorZac Medico <zmedico@gentoo.org>
Tue, 22 May 2007 13:15:38 +0000 (13:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 22 May 2007 13:15:38 +0000 (13:15 -0000)
svn path=/main/branches/2.1.2/; revision=6574

pym/portage_update.py

index 1a2a1d8841ed5c697f4fbaedb01f875aa1978561..c3746d34d132a34c57535b0c23a10e294aa665a8 100644 (file)
@@ -16,7 +16,7 @@ ignored_dbentries = ("CONTENTS", "environment.bz2")
 def update_dbentry(update_cmd, mycontent):
        if update_cmd[0] == "move":
                old_value, new_value = update_cmd[1], update_cmd[2]
-               if mycontent.count(old_value):
+               if old_value in mycontent:
                        old_value = re.escape(old_value);
                        mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
                        def myreplace(matchobj):
@@ -28,7 +28,7 @@ def update_dbentry(update_cmd, mycontent):
        elif update_cmd[0] == "slotmove" and get_operator(update_cmd[1]) is None:
                pkg, origslot, newslot = update_cmd[1:]
                old_value = "%s:%s" % (pkg, origslot)
-               if mycontent.count(old_value):
+               if old_value in mycontent:
                        old_value = re.escape(old_value)
                        new_value = "%s:%s" % (pkg, newslot)
                        mycontent = re.sub(old_value+"($|\\s)", new_value+"\\1", mycontent)