Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
9f19392f
Commit
9f19392f
authored
Nov 08, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os.Expand: don't call append for each non-variable char
R=r CC=golang-dev
https://golang.org/cl/2993041
parent
02469b82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
src/pkg/os/env.go
src/pkg/os/env.go
+9
-9
No files found.
src/pkg/os/env.go
View file @
9f19392f
...
@@ -11,17 +11,17 @@ package os
...
@@ -11,17 +11,17 @@ package os
func
Expand
(
s
string
,
mapping
func
(
string
)
string
)
string
{
func
Expand
(
s
string
,
mapping
func
(
string
)
string
)
string
{
buf
:=
make
([]
byte
,
0
,
2
*
len
(
s
))
buf
:=
make
([]
byte
,
0
,
2
*
len
(
s
))
// ${} is all ASCII, so bytes are fine for this operation.
// ${} is all ASCII, so bytes are fine for this operation.
for
i
:=
0
;
i
<
len
(
s
);
{
i
:=
0
if
s
[
i
]
!=
'$'
||
i
==
len
(
s
)
-
1
{
for
j
:=
0
;
j
<
len
(
s
);
j
++
{
buf
=
append
(
buf
,
s
[
i
])
if
s
[
j
]
==
'$'
&&
j
+
1
<
len
(
s
)
{
i
++
buf
=
append
(
buf
,
[]
byte
(
s
[
i
:
j
])
...
)
continue
name
,
w
:=
getShellName
(
s
[
j
+
1
:
])
buf
=
append
(
buf
,
[]
byte
(
mapping
(
name
))
...
)
j
+=
w
i
=
j
+
1
}
}
name
,
w
:=
getShellName
(
s
[
i
+
1
:
])
buf
=
append
(
buf
,
[]
byte
(
mapping
(
name
))
...
)
i
+=
1
+
w
}
}
return
string
(
buf
)
return
string
(
buf
)
+
s
[
i
:
]
}
}
// ShellExpand replaces ${var} or $var in the string according to the values
// ShellExpand replaces ${var} or $var in the string according to the values
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment