aboutsummaryrefslogtreecommitdiff
path: root/src/text/template
diff options
context:
space:
mode:
authorNathan VanBenschoten <nvanbenschoten@gmail.com>2015-12-22 02:40:47 -0500
committerRuss Cox <rsc@golang.org>2016-02-19 01:06:05 +0000
commitb04f3b06ec347543b0eafe82dcfb0e05885d3feb (patch)
treec9d889546ef895fce8b8a2c04c7e06cc998c1842 /src/text/template
parent952c2fd606fad19b930937ca0d5c5571d7f5d4cb (diff)
downloadgo-b04f3b06ec347543b0eafe82dcfb0e05885d3feb.tar.xz
all: replace strings.Index with strings.Contains where possible
Change-Id: Ia613f1c37bfce800ece0533a5326fca91d99a66a Reviewed-on: https://go-review.googlesource.com/18120 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/text/template')
-rw-r--r--src/text/template/exec.go2
-rw-r--r--src/text/template/funcs.go2
-rw-r--r--src/text/template/parse/lex.go4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index efe1817173..5ea45a4c53 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -446,7 +446,7 @@ func (s *state) idealConstant(constant *parse.NumberNode) reflect.Value {
switch {
case constant.IsComplex:
return reflect.ValueOf(constant.Complex128) // incontrovertible.
- case constant.IsFloat && !isHexConstant(constant.Text) && strings.IndexAny(constant.Text, ".eE") >= 0:
+ case constant.IsFloat && !isHexConstant(constant.Text) && strings.ContainsAny(constant.Text, ".eE"):
return reflect.ValueOf(constant.Float64)
case constant.IsInt:
n := int(constant.Int64)
diff --git a/src/text/template/funcs.go b/src/text/template/funcs.go
index 49e9e7419a..58b8ea372d 100644
--- a/src/text/template/funcs.go
+++ b/src/text/template/funcs.go
@@ -515,7 +515,7 @@ func HTMLEscape(w io.Writer, b []byte) {
// HTMLEscapeString returns the escaped HTML equivalent of the plain text data s.
func HTMLEscapeString(s string) string {
// Avoid allocation if we can.
- if strings.IndexAny(s, `'"&<>`) < 0 {
+ if !strings.ContainsAny(s, `'"&<>`) {
return s
}
var b bytes.Buffer
diff --git a/src/text/template/parse/lex.go b/src/text/template/parse/lex.go
index ea93e05142..079c0ea6f7 100644
--- a/src/text/template/parse/lex.go
+++ b/src/text/template/parse/lex.go
@@ -155,7 +155,7 @@ func (l *lexer) ignore() {
// accept consumes the next rune if it's from the valid set.
func (l *lexer) accept(valid string) bool {
- if strings.IndexRune(valid, l.next()) >= 0 {
+ if strings.ContainsRune(valid, l.next()) {
return true
}
l.backup()
@@ -164,7 +164,7 @@ func (l *lexer) accept(valid string) bool {
// acceptRun consumes a run of runes from the valid set.
func (l *lexer) acceptRun(valid string) {
- for strings.IndexRune(valid, l.next()) >= 0 {
+ for strings.ContainsRune(valid, l.next()) {
}
l.backup()
}