From eb2dc3d3d076f6924b4d25f89de267dc93066ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 11 Sep 2017 21:51:38 +0200 Subject: [PATCH] all: remove strings.Contains check around Replace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í TryBot-Result: Gobot Gobot Reviewed-by: Dave Cheney --- src/path/filepath/path_windows.go | 4 +--- src/text/template/exec.go | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go index 0d8b62015c..03542559f8 100644 --- a/src/path/filepath/path_windows.go +++ b/src/path/filepath/path_windows.go @@ -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 diff --git a/src/text/template/exec.go b/src/text/template/exec.go index e54a579afd..1c361ed13e 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -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