Optimize catpkgsplit() by creating a tuple directly instead of generating it
authorZac Medico <zmedico@gentoo.org>
Mon, 7 Sep 2009 02:58:00 +0000 (02:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 7 Sep 2009 02:58:00 +0000 (02:58 -0000)
from a list. Thanks to Marat Radchenko <slonopotamusorama@gmail.com> for this
patch.

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

pym/portage/versions.py

index abd85d2731f9269706e885e55b6d882bc9bb5b20..f434ff768239727780ec7feddaa64b6516394f12 100644 (file)
@@ -274,16 +274,15 @@ def catpkgsplit(mydata,silent=1):
        mysplit = mydata.split('/', 1)
        p_split=None
        if len(mysplit)==1:
-               retval=["null"]
+               cat = "null"
                p_split=pkgsplit(mydata,silent=silent)
        elif len(mysplit)==2:
-               retval=[mysplit[0]]
+               cat = mysplit[0]
                p_split=pkgsplit(mysplit[1],silent=silent)
        if not p_split:
                catcache[mydata]=None
                return None
-       retval.extend(p_split)
-       retval = tuple(retval)
+       retval = (cat, p_split[0], p_split[1], p_split[2])
        catcache[mydata]=retval
        return retval