From 89f9e1fcfb721a17f8043e0c6231ebe7e986e4b7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 6 Feb 2023 20:56:28 -0500 Subject: Simplify string view interface --- include/zix/string_view.h | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'include/zix') 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(); } /** -- cgit v1.2.1