aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-05-08 21:29:52 -0400
committerDavid Robillard <d@drobilla.net>2023-05-08 21:29:52 -0400
commit86894351ffb6cc7f9fd9a4d63ba0a6eecc64d29d (patch)
treecf08668affe83c2a0eb9c9e2eb16689c5b3517f6 /src/uri.c
parented77fe14175e94138390f2ebf5348656e4421746 (diff)
downloadserd-86894351ffb6cc7f9fd9a4d63ba0a6eecc64d29d.tar.gz
serd-86894351ffb6cc7f9fd9a4d63ba0a6eecc64d29d.tar.bz2
serd-86894351ffb6cc7f9fd9a4d63ba0a6eecc64d29d.zip
Avoid use of strtoul()
This function is overkill for the simple cases actually needed here, and pretty slow anyway.
Diffstat (limited to 'src/uri.c')
-rw-r--r--src/uri.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/uri.c b/src/uri.c
index d78b8e8c..b45f7e16 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -72,8 +72,9 @@ serd_file_uri_parse(const uint8_t* const uri, uint8_t** const hostname)
serd_chunk_sink("%", 1, &chunk);
++s;
} else if (is_hexdig(*(s + 1)) && is_hexdig(*(s + 2))) {
- const uint8_t code[3] = {*(s + 1), *(s + 2), 0};
- const uint8_t c = (uint8_t)strtoul((const char*)code, NULL, 16);
+ const uint8_t hi = hex_digit_value(s[1]);
+ const uint8_t lo = hex_digit_value(s[2]);
+ const char c = (char)((hi << 4U) | lo);
serd_chunk_sink(&c, 1, &chunk);
s += 2;
} else {