aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/http.go
diff options
context:
space:
mode:
authorMarvin Stenger <marvin.stenger94@gmail.com>2017-09-25 15:47:44 +0200
committerIan Lance Taylor <iant@golang.org>2017-09-27 00:54:24 +0000
commitd2826d3e068f096f4b5371175afb7e5d8c4aa73c (patch)
treee252245e001e359351b9a06891cadf6d725231b9 /src/net/http/http.go
parente61c5e2f2044c7bc606ebdfbd0187598b90c50e5 (diff)
downloadgo-d2826d3e068f096f4b5371175afb7e5d8c4aa73c.tar.xz
all: prefer strings.LastIndexByte over strings.LastIndex
strings.LastIndexByte was introduced in go1.5 and it can be used effectively wherever the second argument to strings.LastIndex is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.LastIndex. Change-Id: I7b5679d616197b055cffe6882a8675d24a98b574 Reviewed-on: https://go-review.googlesource.com/66372 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/http.go')
-rw-r--r--src/net/http/http.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net/http/http.go b/src/net/http/http.go
index b95ca89f40..7d5b74092e 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -35,7 +35,7 @@ func (k *contextKey) String() string { return "net/http context value " + k.name
// Given a string of the form "host", "host:port", or "[ipv6::address]:port",
// return true if the string includes a port.
-func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") }
+func hasPort(s string) bool { return strings.LastIndexByte(s, ':') > strings.LastIndexByte(s, ']') }
// removeEmptyPort strips the empty port in ":port" to ""
// as mandated by RFC 3986 Section 6.2.3.