diff options
author | ZYunH <zyunhjob@163.com> | 2019-09-19 19:15:51 +0800 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2019-09-19 13:15:51 +0200 |
commit | 9bc19f85e1ab5325c02101e27b4050330805c17d (patch) | |
tree | dcd2d7fafb2896db1c8b3003c54e8b27f024ecc0 /bytesconv.go | |
parent | Update README.md (diff) | |
download | fasthttp-9bc19f85e1ab5325c02101e27b4050330805c17d.tar.gz fasthttp-9bc19f85e1ab5325c02101e27b4050330805c17d.tar.bz2 fasthttp-9bc19f85e1ab5325c02101e27b4050330805c17d.zip |
Replace hexCharUpeer with upperhex (#657)
Diffstat (limited to 'bytesconv.go')
-rw-r--r-- | bytesconv.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/bytesconv.go b/bytesconv.go index e0ca3ab..5d87908 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -315,13 +315,6 @@ func int2hexbyte(n int) byte { return 'a' + byte(n) - 10 } -func hexCharUpper(c byte) byte { - if c < 10 { - return '0' + c - } - return c - 10 + 'A' -} - var hex2intTable = func() []byte { b := make([]byte, 256) for i := 0; i < 256; i++ { @@ -338,7 +331,10 @@ var hex2intTable = func() []byte { return b }() -const toLower = 'a' - 'A' +const ( + toLower = 'a' - 'A' + upperhex = "0123456789ABCDEF" +) var toLowerTable = func() [256]byte { var a [256]byte @@ -459,7 +455,7 @@ func AppendQuotedArg(dst, src []byte) []byte { case c == ' ': dst = append(dst, '+') case quotedArgShouldEscapeTable[int(c)]: - dst = append(dst, '%', hexCharUpper(c>>4), hexCharUpper(c&15)) + dst = append(dst, '%', upperhex[c>>4], upperhex[c&15]) default: dst = append(dst, c) } @@ -475,7 +471,7 @@ func appendQuotedPath(dst, src []byte) []byte { for _, c := range src { if quotedPathShouldEscapeTable[int(c)] { - dst = append(dst, '%', hexCharUpper(c>>4), hexCharUpper(c&15)) + dst = append(dst, '%', upperhex[c>>4], upperhex[c&15]) } else { dst = append(dst, c) } |