1 |
commit: 7490a70d40ed47e064a08f10b2319a4b8c9180d9 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Mar 31 19:48:44 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Mar 31 19:48:44 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7490a70d |
7 |
|
8 |
varexpand: use list for efficient append |
9 |
|
10 |
--- |
11 |
pym/portage/util/__init__.py | 26 +++++++++++++------------- |
12 |
1 files changed, 13 insertions(+), 13 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py |
15 |
index fc4b75b..ae560c0 100644 |
16 |
--- a/pym/portage/util/__init__.py |
17 |
+++ b/pym/portage/util/__init__.py |
18 |
@@ -661,21 +661,21 @@ def varexpand(mystring, mydict=None): |
19 |
insing=0 |
20 |
indoub=0 |
21 |
pos=1 |
22 |
- newstring = "" |
23 |
+ newstring = [] |
24 |
while (pos<len(mystring)): |
25 |
if (mystring[pos]=="'") and (mystring[pos-1]!="\\"): |
26 |
if (indoub): |
27 |
- newstring=newstring+"'" |
28 |
+ newstring.append("'") |
29 |
else: |
30 |
- newstring += "'" # Quote removal is handled by shlex. |
31 |
+ newstring.append("'") # Quote removal is handled by shlex. |
32 |
insing=not insing |
33 |
pos=pos+1 |
34 |
continue |
35 |
elif (mystring[pos]=='"') and (mystring[pos-1]!="\\"): |
36 |
if (insing): |
37 |
- newstring=newstring+'"' |
38 |
+ newstring.append('"') |
39 |
else: |
40 |
- newstring += '"' # Quote removal is handled by shlex. |
41 |
+ newstring.append('"') # Quote removal is handled by shlex. |
42 |
indoub=not indoub |
43 |
pos=pos+1 |
44 |
continue |
45 |
@@ -683,7 +683,7 @@ def varexpand(mystring, mydict=None): |
46 |
#expansion time |
47 |
if (mystring[pos]=="\n"): |
48 |
#convert newlines to spaces |
49 |
- newstring=newstring+" " |
50 |
+ newstring.append(" ") |
51 |
pos=pos+1 |
52 |
elif (mystring[pos]=="\\"): |
53 |
# For backslash expansion, this function used to behave like |
54 |
@@ -695,17 +695,17 @@ def varexpand(mystring, mydict=None): |
55 |
# escaped quotes here, since getconfig() uses shlex |
56 |
# to handle that earlier. |
57 |
if (pos+1>=len(mystring)): |
58 |
- newstring=newstring+mystring[pos] |
59 |
+ newstring.append(mystring[pos]) |
60 |
break |
61 |
else: |
62 |
a = mystring[pos + 1] |
63 |
pos = pos + 2 |
64 |
if a in ("\\", "$"): |
65 |
- newstring = newstring + a |
66 |
+ newstring.append(a) |
67 |
elif a == "\n": |
68 |
pass |
69 |
else: |
70 |
- newstring = newstring + mystring[pos-2:pos] |
71 |
+ newstring.append(mystring[pos - 2:pos]) |
72 |
continue |
73 |
elif (mystring[pos]=="$") and (mystring[pos-1]!="\\"): |
74 |
pos=pos+1 |
75 |
@@ -734,15 +734,15 @@ def varexpand(mystring, mydict=None): |
76 |
return "" |
77 |
numvars=numvars+1 |
78 |
if myvarname in mydict: |
79 |
- newstring=newstring+mydict[myvarname] |
80 |
+ newstring.append(mydict[myvarname]) |
81 |
else: |
82 |
- newstring=newstring+mystring[pos] |
83 |
+ newstring.append(mystring[pos]) |
84 |
pos=pos+1 |
85 |
else: |
86 |
- newstring=newstring+mystring[pos] |
87 |
+ newstring.append(mystring[pos]) |
88 |
pos=pos+1 |
89 |
|
90 |
- return newstring |
91 |
+ return "".join(newstring) |
92 |
|
93 |
# broken and removed, but can still be imported |
94 |
pickle_write = None |