Skip to content

Commit

Permalink
net/url: add upperhex const instead of using string literal
Browse files Browse the repository at this point in the history
The mime and strconv packages already have a const with this name & value.

Change-Id: Ibd7837f854ac8ec3f57943a9d1db07f4cf6db858
GitHub-Last-Rev: 775cdce
GitHub-Pull-Request: #34389
Reviewed-on: https://go-review.googlesource.com/c/go/+/196437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
zhangyunhao116 authored and bradfitz committed Sep 19, 2019
1 parent e53edaf commit fe2ed50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/net/url/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit fe2ed50

Please sign in to comment.