aboutsummaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2017-09-11 21:51:38 +0200
committerDaniel Martí <mvdan@mvdan.cc>2017-09-12 08:58:28 +0000
commiteb2dc3d3d076f6924b4d25f89de267dc93066ea5 (patch)
tree042081fac5d6d633c1ac1fd3f3416734fffccc3c /src/text
parent137e4a6c63e8688cba34df7dad81b45f0aaa500c (diff)
downloadgo-eb2dc3d3d076f6924b4d25f89de267dc93066ea5.tar.xz
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>
Diffstat (limited to 'src/text')
-rw-r--r--src/text/template/exec.go5
1 files changed, 1 insertions, 4 deletions
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