From 0703ba118b56aaa924346ae36c8826764dadd409 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 18 Oct 2024 17:19:57 -0400 Subject: [PATCH] AK: Add a comparison operator for Utf32View --- AK/Utf32View.cpp | 8 ++++++++ AK/Utf32View.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/AK/Utf32View.cpp b/AK/Utf32View.cpp index ebb4bbd1f7a..a482aa54f1f 100644 --- a/AK/Utf32View.cpp +++ b/AK/Utf32View.cpp @@ -27,6 +27,14 @@ Optional Utf32CodePointIterator::peek(size_t offset) const return *new_iterator; } +bool Utf32View::operator==(Utf32View const& other) const +{ + ReadonlySpan code_points { m_code_points, m_length }; + ReadonlySpan other_code_points { other.m_code_points, other.m_length }; + + return code_points == other_code_points; +} + ErrorOr Formatter::format(FormatBuilder& builder, Utf32View const& string) { return builder.builder().try_append(string); diff --git a/AK/Utf32View.h b/AK/Utf32View.h index 3a522471b1e..b030d64b1fa 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -119,6 +119,8 @@ public: return substring_view(offset, length() - offset); } + bool operator==(Utf32View const& other) const; + private: u32 const* begin_ptr() const {