From f22ba1f24786be600bfa3686a7ce5a318a96b9c9 Mon Sep 17 00:00:00 2001 From: Marvin Stenger Date: Thu, 21 Sep 2017 19:01:27 +0200 Subject: all: prefer strings.IndexByte over strings.Index strings.IndexByte was introduced in go1.2 and it can be used effectively wherever the second argument to strings.Index is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.Index. Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793 Reviewed-on: https://go-review.googlesource.com/65930 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/encoding/xml/typeinfo.go | 2 +- src/encoding/xml/xml.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/encoding/xml') diff --git a/src/encoding/xml/typeinfo.go b/src/encoding/xml/typeinfo.go index 2e7ae935a8..b3346d304e 100644 --- a/src/encoding/xml/typeinfo.go +++ b/src/encoding/xml/typeinfo.go @@ -115,7 +115,7 @@ func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro // Split the tag from the xml namespace if necessary. tag := f.Tag.Get("xml") - if i := strings.Index(tag, " "); i >= 0 { + if i := strings.IndexByte(tag, ' '); i >= 0 { finfo.xmlns, tag = tag[:i], tag[i+1:] } diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go index be90b62c9a..27b871649b 100644 --- a/src/encoding/xml/xml.go +++ b/src/encoding/xml/xml.go @@ -1161,7 +1161,7 @@ func (d *Decoder) nsname() (name Name, ok bool) { if !ok { return } - i := strings.Index(s, ":") + i := strings.IndexByte(s, ':') if i < 0 { name.Local = s } else { -- cgit v1.3-5-g9baa