From b3135e944d386d28a6475cb58e47647ff559bca1 Mon Sep 17 00:00:00 2001 From: ksw2000 <13825170+ksw2000@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:52:22 +0800 Subject: [PATCH] improve ishex and unhex by hex2intTable --- uri.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/uri.go b/uri.go index 7ddadfcbe2..cca09517a2 100644 --- a/uri.go +++ b/uri.go @@ -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