diff options
author | David Robillard <d@drobilla.net> | 2023-02-06 20:56:28 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-02-06 20:56:28 -0500 |
commit | 89f9e1fcfb721a17f8043e0c6231ebe7e986e4b7 (patch) | |
tree | d8ec7131fbc601d1576f4c42c3d07d81f3db06de /include/zix | |
parent | 18e62483cb7173c6604f7dd2097299e47c2a4c0c (diff) | |
download | zix-89f9e1fcfb721a17f8043e0c6231ebe7e986e4b7.tar.gz zix-89f9e1fcfb721a17f8043e0c6231ebe7e986e4b7.tar.bz2 zix-89f9e1fcfb721a17f8043e0c6231ebe7e986e4b7.zip |
Simplify string view interface
Diffstat (limited to 'include/zix')
-rw-r--r-- | include/zix/string_view.h | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/include/zix/string_view.h b/include/zix/string_view.h index f4cd6c2..f1fe009 100644 --- a/include/zix/string_view.h +++ b/include/zix/string_view.h @@ -71,24 +71,10 @@ zix_substring(const char* const ZIX_NONNULL str, const size_t len) ZIX_ALWAYS_INLINE_FUNC ZIX_PURE_FUNC static inline ZixStringView -zix_string(const char* const ZIX_NONNULL str) +// NOLINTNEXTLINE(clang-diagnostic-unused-function) +zix_string(const char* const ZIX_NULLABLE str) { - const ZixStringView view = {str, strlen(str)}; - return view; -} - -/** - Return a view of an entire string by measuring it. - - This makes a view of the given string by measuring it with `strlen`. - - @param str Pointer to the start of a null-terminated C string, or null. -*/ -ZIX_PURE_FUNC -static inline ZixStringView -zix_optional_string(const char* const ZIX_NULLABLE str) -{ - return str ? zix_string(str) : zix_empty_string(); + return str ? zix_substring(str, strlen(str)) : zix_empty_string(); } /** |