diff options
author | Marvin Stenger <marvin.stenger94@gmail.com> | 2017-09-21 19:01:27 +0200 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2017-09-25 17:35:41 +0000 |
commit | f22ba1f24786be600bfa3686a7ce5a318a96b9c9 (patch) | |
tree | 06dd4fd49b65d66491a3674f8ed440fd44f52cc5 /src/net/http/request.go | |
parent | 5e92c411284f1757c3531a70530170f1079ee5fc (diff) | |
download | go-git-f22ba1f24786be600bfa3686a7ce5a318a96b9c9.tar.gz |
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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http/request.go')
-rw-r--r-- | src/net/http/request.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net/http/request.go b/src/net/http/request.go index 870af85e04..b7fcf806ba 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -712,7 +712,7 @@ func ParseHTTPVersion(vers string) (major, minor int, ok bool) { if !strings.HasPrefix(vers, "HTTP/") { return 0, 0, false } - dot := strings.Index(vers, ".") + dot := strings.IndexByte(vers, '.') if dot < 0 { return 0, 0, false } @@ -880,8 +880,8 @@ func (r *Request) SetBasicAuth(username, password string) { // parseRequestLine parses "GET /foo HTTP/1.1" into its three parts. func parseRequestLine(line string) (method, requestURI, proto string, ok bool) { - s1 := strings.Index(line, " ") - s2 := strings.Index(line[s1+1:], " ") + s1 := strings.IndexByte(line, ' ') + s2 := strings.IndexByte(line[s1+1:], ' ') if s1 < 0 || s2 < 0 { return } |