]> Cypherpunks repositories - gostls13.git/commitdiff
html/template: use bytes.ContainsAny
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 25 Apr 2017 11:57:33 +0000 (12:57 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 25 Apr 2017 23:36:25 +0000 (23:36 +0000)
It was added in Go 1.7. Also gofmt while at it.

Change-Id: Idb65fb44e2f2a4365dceea3f833aeb51a8d12333
Reviewed-on: https://go-review.googlesource.com/41692
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/html/template/escape.go
src/html/template/transition.go

index 106067f7928940339b21da56bd0100c793f876e3..3e8b455e33da57f10842914b89905349e8c37328 100644 (file)
@@ -64,7 +64,7 @@ var funcMap = template.FuncMap{
 
 // predefinedEscapers contains template predefined escapers.
 var predefinedEscapers = map[string]bool{
-       "html" :    true,
+       "html"    true,
        "urlquery": true,
        "js":       true,
 }
@@ -155,8 +155,8 @@ func (e *escaper) escapeAction(c context, n *parse.ActionNode) context {
                for _, ident := range allIdents(idNode.Args[0]) {
                        if _, ok := predefinedEscapers[ident]; ok {
                                return context{
-                               state: stateError,
-                               err:   errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident),
+                                       state: stateError,
+                                       err:   errorf(ErrPredefinedEscaper, n, n.Line, "predefined escaper %q disallowed in template", ident),
                                }
                        }
                }
@@ -582,7 +582,7 @@ func (e *escaper) escapeText(c context, n *parse.TextNode) context {
                                // the entire comment is considered to be a
                                // LineTerminator for purposes of parsing by
                                // the syntactic grammar."
-                               if bytes.IndexAny(s[written:i1], "\n\r\u2028\u2029") != -1 {
+                               if bytes.ContainsAny(s[written:i1], "\n\r\u2028\u2029") {
                                        b.WriteByte('\n')
                                } else {
                                        b.WriteByte(' ')
index 5d34d6947e94cd958eccbdda8d96d27be061d62d..df7ac2289b456c4d4bc81d6a1ce39ca57b1f48bf 100644 (file)
@@ -246,7 +246,7 @@ func tAttr(c context, s []byte) (context, int) {
 
 // tURL is the context transition function for the URL state.
 func tURL(c context, s []byte) (context, int) {
-       if bytes.IndexAny(s, "#?") >= 0 {
+       if bytes.ContainsAny(s, "#?") {
                c.urlPart = urlPartQueryOrFrag
        } else if len(s) != eatWhiteSpace(s, 0) && c.urlPart == urlPartNone {
                // HTML5 uses "Valid URL potentially surrounded by spaces" for