aboutsummaryrefslogtreecommitdiffstats
path: root/src/string_utils.h
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/string_utils.h
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/string_utils.h')
-rw-r--r--src/string_utils.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/string_utils.h b/src/string_utils.h
index 9ae0abcb..7770e1eb 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -89,6 +89,12 @@ serd_substrlen(const uint8_t* str,
size_t* n_bytes,
SerdNodeFlags* flags);
+static inline uint8_t
+hex_digit_value(const uint8_t c)
+{
+ return (uint8_t)((c > '9') ? ((c & ~0x20) - 'A' + 10) : (c - '0'));
+}
+
static inline char
serd_to_upper(const char c)
{