Skip to content

Commit

Permalink
improve ishex and unhex by hex2intTable
Browse files Browse the repository at this point in the history
  • Loading branch information
ksw2000 committed Oct 8, 2024
1 parent 6ac5603 commit b3135e9
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,21 +536,11 @@ func shouldEscape(c byte, mode encoding) bool {
}

func ishex(c byte) bool {
return ('0' <= c && c <= '9') ||
('a' <= c && c <= 'f') ||
('A' <= c && c <= 'F')
return hex2intTable[c] < 16
}

func unhex(c byte) byte {
switch {
case '0' <= c && c <= '9':
return c - '0'
case 'a' <= c && c <= 'f':
return c - 'a' + 10
case 'A' <= c && c <= 'F':
return c - 'A' + 10
}
return 0
return hex2intTable[c] & 15
}

// validOptionalPort reports whether port is either an empty string
Expand Down

0 comments on commit b3135e9

Please sign in to comment.