From aec0d760835219f91eb483c68ef7b2c8f9e8597e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 26 Jun 2024 18:48:02 -0400 Subject: Add zix_string_view_equals() --- include/zix/string_view.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'include') 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 +// Copyright 2011-2024 David Robillard // SPDX-License-Identifier: ISC #ifndef ZIX_STRING_VIEW_H @@ -7,6 +7,7 @@ #include "zix/allocator.h" #include "zix/attributes.h" +#include #include #include @@ -93,6 +94,17 @@ ZIX_MALLOC_API 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); + /** @} */ -- cgit v1.2.1