From 55fa51b4e22a01efc258c99ae059364595ad74a3 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 18 Jul 2021 05:01:18 +0430 Subject: [PATCH] AK: Add a is_null() method to Utf{8,32}View Both of these can be null as well as empty, and there's a difference. --- AK/Utf32View.h | 1 + AK/Utf8View.h | 1 + 2 files changed, 2 insertions(+) diff --git a/AK/Utf32View.h b/AK/Utf32View.h index d210ec7eaf..cb3c5ae44d 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -83,6 +83,7 @@ public: const u32* code_points() const { return m_code_points; } bool is_empty() const { return m_length == 0; } + bool is_null() const { return !m_code_points; } size_t length() const { return m_length; } size_t iterator_offset(const Utf32CodePointIterator& it) const diff --git a/AK/Utf8View.h b/AK/Utf8View.h index e8afc590a6..5832c6c9fc 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -74,6 +74,7 @@ public: Utf8View unicode_substring_view(size_t code_point_offset) const { return unicode_substring_view(code_point_offset, length() - code_point_offset); } bool is_empty() const { return m_string.is_empty(); } + bool is_null() const { return m_string.is_null(); } bool starts_with(const Utf8View&) const; bool contains(u32) const;