From: Zac Medico Date: Sat, 31 Mar 2012 19:48:44 +0000 (-0700) Subject: varexpand: use list for efficient append X-Git-Tag: v2.2.0_alpha97~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7490a70d40ed47e064a08f10b2319a4b8c9180d9;p=portage.git varexpand: use list for efficient append --- diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index fc4b75b20..ae560c0d5 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -661,21 +661,21 @@ def varexpand(mystring, mydict=None): insing=0 indoub=0 pos=1 - newstring = "" + newstring = [] while (pos=len(mystring)): - newstring=newstring+mystring[pos] + newstring.append(mystring[pos]) break else: a = mystring[pos + 1] pos = pos + 2 if a in ("\\", "$"): - newstring = newstring + a + newstring.append(a) elif a == "\n": pass else: - newstring = newstring + mystring[pos-2:pos] + newstring.append(mystring[pos - 2:pos]) continue elif (mystring[pos]=="$") and (mystring[pos-1]!="\\"): pos=pos+1 @@ -734,15 +734,15 @@ def varexpand(mystring, mydict=None): return "" numvars=numvars+1 if myvarname in mydict: - newstring=newstring+mydict[myvarname] + newstring.append(mydict[myvarname]) else: - newstring=newstring+mystring[pos] + newstring.append(mystring[pos]) pos=pos+1 else: - newstring=newstring+mystring[pos] + newstring.append(mystring[pos]) pos=pos+1 - return newstring + return "".join(newstring) # broken and removed, but can still be imported pickle_write = None