Skip to content

Commit eb2dc3d

Browse files
committed
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í <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Dave Cheney <[email protected]>
1 parent 137e4a6 commit eb2dc3d

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/path/filepath/path_windows.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ func splitList(path string) []string {
100100

101101
// Remove quotes.
102102
for i, s := range list {
103-
if strings.Contains(s, `"`) {
104-
list[i] = strings.Replace(s, `"`, ``, -1)
105-
}
103+
list[i] = strings.Replace(s, `"`, ``, -1)
106104
}
107105

108106
return list

src/text/template/exec.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ func (s *state) at(node parse.Node) {
7979
// doublePercent returns the string with %'s replaced by %%, if necessary,
8080
// so it can be used safely inside a Printf format string.
8181
func doublePercent(str string) string {
82-
if strings.Contains(str, "%") {
83-
str = strings.Replace(str, "%", "%%", -1)
84-
}
85-
return str
82+
return strings.Replace(str, "%", "%%", -1)
8683
}
8784

8885
// TODO: It would be nice if ExecError was more broken down, but

0 commit comments

Comments
 (0)