From: Zac Medico Date: Thu, 7 Jun 2007 14:47:39 +0000 (-0000) Subject: Make pkgsplit and catpkgsplit return imutable tuples instead of mutable lists so... X-Git-Tag: v2.2_pre1~1282 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=42c29e4246af51f221c7030c443771be6ca45d2f;p=portage.git Make pkgsplit and catpkgsplit return imutable tuples instead of mutable lists so that cached values can be safely returned without cloning them first. Thanks to Brian Harring for the suggestion. svn path=/main/trunk/; revision=6749 --- diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index 67d70bee1..0db3862f3 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -2684,7 +2684,7 @@ class depgraph: else: verboseadd += "[No ebuild?]" - xs=portage.pkgsplit(x[2]) + xs = list(portage.pkgsplit(x[2])) if xs[2]=="r0": xs[2]="" else: diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 95d7340a3..ebf8cbada 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -200,7 +200,7 @@ def pkgsplit(mypkg,silent=1): try: if not pkgcache[mypkg]: return None - return pkgcache[mypkg][:] + return pkgcache[mypkg] except KeyError: pass myparts=mypkg.split("-") @@ -243,9 +243,9 @@ def pkgsplit(mypkg,silent=1): pkgcache[mypkg]=None return None #names can't have versiony looking parts - myval=["-".join(myparts[:verPos]),myparts[verPos],revision] + myval=("-".join(myparts[:verPos]),myparts[verPos],revision) pkgcache[mypkg]=myval - return myval[:] + return myval else: pkgcache[mypkg]=None return None @@ -273,7 +273,7 @@ def catpkgsplit(mydata,silent=1): try: if not catcache[mydata]: return None - return catcache[mydata][:] + return catcache[mydata] except KeyError: pass mysplit=mydata.split("/") @@ -288,8 +288,9 @@ def catpkgsplit(mydata,silent=1): catcache[mydata]=None return None retval.extend(p_split) + retval = tuple(retval) catcache[mydata]=retval - return retval[:] + return retval def catsplit(mydep): return mydep.split("/", 1)