From a245ea1743f2ddb87003c56ac96786543bdd8839 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 18 Jul 2021 05:02:31 +0430 Subject: [PATCH] AK: Add the at()/operator[]() getter to Utf32View This is trivial, and makes it easier to get the code point compared to the previous `.code_points()[index]` (which was not actually checked for in-bounds length). --- AK/Utf32View.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AK/Utf32View.h b/AK/Utf32View.h index cb3c5ae44de..75c7d2c0d98 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -81,6 +81,14 @@ public: return { end_ptr(), 0 }; } + u32 at(size_t index) const + { + VERIFY(index < m_length); + return m_code_points[index]; + } + + u32 operator[](size_t index) const { return at(index); } + 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; }