summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-07 23:47:05 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-07 23:47:05 +0000
commitf49b6dbd5b5428afda1cd3ea9694375c875db7aa (patch)
treee4a7cacc2fccc0047e87dccaa49778d51a5f777d /src/utils
parent54c6f7d1ff97104322d14684644cbdeb04e85b57 (diff)
downloadlibcss-f49b6dbd5b5428afda1cd3ea9694375c875db7aa.tar.gz
libcss-f49b6dbd5b5428afda1cd3ea9694375c875db7aa.tar.bz2
Simplify charToHex()
svn path=/trunk/libcss/; revision=8384
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/utils.h45
1 files changed, 9 insertions, 36 deletions
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 4661442..1c380f8 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -45,42 +45,15 @@ static inline bool isHex(uint8_t c)
static inline uint32_t charToHex(uint8_t c)
{
- switch (c) {
- case 'a': case 'A':
- return 0xa;
- case 'b': case 'B':
- return 0xb;
- case 'c': case 'C':
- return 0xc;
- case 'd': case 'D':
- return 0xd;
- case 'e': case 'E':
- return 0xe;
- case 'f': case 'F':
- return 0xf;
- case '0':
- return 0x0;
- case '1':
- return 0x1;
- case '2':
- return 0x2;
- case '3':
- return 0x3;
- case '4':
- return 0x4;
- case '5':
- return 0x5;
- case '6':
- return 0x6;
- case '7':
- return 0x7;
- case '8':
- return 0x8;
- case '9':
- return 0x9;
- }
-
- return 0;
+ c -= '0';
+
+ if (c > 9)
+ c -= 'A' - '9' - 1;
+
+ if (c > 15)
+ c -= 'a' - 'A';
+
+ return c;
}
static inline css_error