From: ZYunH Date: Thu, 19 Sep 2019 14:56:11 +0000 (+0000) Subject: net/url: add upperhex const instead of using string literal X-Git-Tag: go1.14beta1~1038 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fe2ed5054176935d4adcf13e891715ccf2ee3cce;p=gostls13.git net/url: add upperhex const instead of using string literal The mime and strconv packages already have a const with this name & value. Change-Id: Ibd7837f854ac8ec3f57943a9d1db07f4cf6db858 GitHub-Last-Rev: 775cdce3b75350aa3b9a6f31f04cfdd0033e9ac3 GitHub-Pull-Request: golang/go#34389 Reviewed-on: https://go-review.googlesource.com/c/go/+/196437 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/net/url/url.go b/src/net/url/url.go index bd706eac84..6f4d5a1ce7 100644 --- a/src/net/url/url.go +++ b/src/net/url/url.go @@ -42,6 +42,8 @@ func (e *Error) Temporary() bool { return ok && t.Temporary() } +const upperhex = "0123456789ABCDEF" + func ishex(c byte) bool { switch { case '0' <= c && c <= '9': @@ -324,8 +326,8 @@ func escape(s string, mode encoding) string { j++ case shouldEscape(c, mode): t[j] = '%' - t[j+1] = "0123456789ABCDEF"[c>>4] - t[j+2] = "0123456789ABCDEF"[c&15] + t[j+1] = upperhex[c>>4] + t[j+2] = upperhex[c&15] j += 3 default: t[j] = s[i]