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/net/http/request.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/net/http/request.go') 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 } -- cgit v1.2.1