mirror of
https://github.com/golang/go
synced 2024-11-19 16:44:43 -07:00
all: remove strings.Contains check around Replace
It doesn't change the outcome. It might have been useful at some point to avoid Replace from doing work or allocating. However, nowadays the func returns early without doing any work if Count returns 0. Change-Id: Id69dc74042a6e39672b405016484db8b50f43d58 Reviewed-on: https://go-review.googlesource.com/62991 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
parent
137e4a6c63
commit
eb2dc3d3d0
@ -100,9 +100,7 @@ func splitList(path string) []string {
|
||||
|
||||
// Remove quotes.
|
||||
for i, s := range list {
|
||||
if strings.Contains(s, `"`) {
|
||||
list[i] = strings.Replace(s, `"`, ``, -1)
|
||||
}
|
||||
list[i] = strings.Replace(s, `"`, ``, -1)
|
||||
}
|
||||
|
||||
return list
|
||||
|
@ -79,10 +79,7 @@ func (s *state) at(node parse.Node) {
|
||||
// doublePercent returns the string with %'s replaced by %%, if necessary,
|
||||
// so it can be used safely inside a Printf format string.
|
||||
func doublePercent(str string) string {
|
||||
if strings.Contains(str, "%") {
|
||||
str = strings.Replace(str, "%", "%%", -1)
|
||||
}
|
||||
return str
|
||||
return strings.Replace(str, "%", "%%", -1)
|
||||
}
|
||||
|
||||
// TODO: It would be nice if ExecError was more broken down, but
|
||||
|
Loading…
Reference in New Issue
Block a user