]> git.ipfire.org Git - thirdparty/opentracker.git/commitdiff
Make fromhex() even faster
authorerdgeist <>
Thu, 18 Oct 2007 11:50:54 +0000 (11:50 +0000)
committererdgeist <>
Thu, 18 Oct 2007 11:50:54 +0000 (11:50 +0000)
scan_urlencoded_query.c

index f61d79e8a071577bd1fe702bf6896d4be1670382..a11b65cc3c3ad97e37b2324c513ec1521b504292 100644 (file)
@@ -25,10 +25,10 @@ static const unsigned char is_unreserved[256] = {
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 };
 
-static unsigned char fromhex(unsigned char c) {
-  if (c>='0' && c<='9') return c-'0';
-  c &= 0xdf; /* Toggle off lower case bit */
-  if (c>='A' && c<='F') return c-'A'+10;
+static unsigned char fromhex(unsigned char x) {
+  x-='0'; if( x<=9) return x;
+  x&=~0x20; x-='A'-'0';
+  if( x<6 ) return x+10;
   return 0xff;
 }