diff options
author | David Robillard <d@drobilla.net> | 2024-06-26 18:48:02 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-06-26 18:52:29 -0400 |
commit | aec0d760835219f91eb483c68ef7b2c8f9e8597e (patch) | |
tree | e732377408502d555e53cd67ddf86986da3cee2c /include | |
parent | c147881d999fa966ea266d6feac2a3fabeef511b (diff) | |
download | zix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.tar.gz zix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.tar.bz2 zix-aec0d760835219f91eb483c68ef7b2c8f9e8597e.zip |
Add zix_string_view_equals()
Diffstat (limited to 'include')
-rw-r--r-- | include/zix/string_view.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/zix/string_view.h b/include/zix/string_view.h index f463c1f..cfd478d 100644 --- a/include/zix/string_view.h +++ b/include/zix/string_view.h @@ -1,4 +1,4 @@ -// Copyright 2011-2023 David Robillard <d@drobilla.net> +// Copyright 2011-2024 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC #ifndef ZIX_STRING_VIEW_H @@ -7,6 +7,7 @@ #include "zix/allocator.h" #include "zix/attributes.h" +#include <stdbool.h> #include <stddef.h> #include <string.h> @@ -94,6 +95,17 @@ char* ZIX_ALLOCATED zix_string_view_copy(ZixAllocator* ZIX_NULLABLE allocator, ZixStringView view); /** + Return true if both string views refer to equal strings. + + This may be significantly faster than a full string comparison, because it + has fast paths for when the operands have different lengths, or point to the + same string data. +*/ +ZIX_PURE_API +bool +zix_string_view_equals(ZixStringView lhs, ZixStringView rhs); + +/** @} */ |