diff options
author | David Robillard <d@drobilla.net> | 2023-05-08 21:29:52 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-05-08 21:29:52 -0400 |
commit | 86894351ffb6cc7f9fd9a4d63ba0a6eecc64d29d (patch) | |
tree | cf08668affe83c2a0eb9c9e2eb16689c5b3517f6 /src/uri.c | |
parent | ed77fe14175e94138390f2ebf5348656e4421746 (diff) | |
download | serd-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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 { |