summaryrefslogtreecommitdiffstats
path: root/pym/portage/util/__init__.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-03-31 12:48:44 -0700
committerZac Medico <zmedico@gentoo.org>2012-03-31 12:48:44 -0700
commit7490a70d40ed47e064a08f10b2319a4b8c9180d9 (patch)
tree3e9b554c0d991a364762b0e21d64c07b9f41934c /pym/portage/util/__init__.py
parent3f7a3b294dd38c6009d41ce7f40075e2e2645c6e (diff)
downloadportage-7490a70d40ed47e064a08f10b2319a4b8c9180d9.tar.gz
portage-7490a70d40ed47e064a08f10b2319a4b8c9180d9.tar.bz2
portage-7490a70d40ed47e064a08f10b2319a4b8c9180d9.zip
varexpand: use list for efficient append
Diffstat (limited to 'pym/portage/util/__init__.py')
-rw-r--r--pym/portage/util/__init__.py26
1 files changed, 13 insertions, 13 deletions
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)):
if (mystring[pos]=="'") and (mystring[pos-1]!="\\"):
if (indoub):
- newstring=newstring+"'"
+ newstring.append("'")
else:
- newstring += "'" # Quote removal is handled by shlex.
+ newstring.append("'") # Quote removal is handled by shlex.
insing=not insing
pos=pos+1
continue
elif (mystring[pos]=='"') and (mystring[pos-1]!="\\"):
if (insing):
- newstring=newstring+'"'
+ newstring.append('"')
else:
- newstring += '"' # Quote removal is handled by shlex.
+ newstring.append('"') # Quote removal is handled by shlex.
indoub=not indoub
pos=pos+1
continue
@@ -683,7 +683,7 @@ def varexpand(mystring, mydict=None):
#expansion time
if (mystring[pos]=="\n"):
#convert newlines to spaces
- newstring=newstring+" "
+ newstring.append(" ")
pos=pos+1
elif (mystring[pos]=="\\"):
# For backslash expansion, this function used to behave like
@@ -695,17 +695,17 @@ def varexpand(mystring, mydict=None):
# escaped quotes here, since getconfig() uses shlex
# to handle that earlier.
if (pos+1>=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