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).
This commit is contained in:
Ali Mohammad Pur 2021-07-18 05:02:31 +04:30 committed by Ali Mohammad Pur
parent 55fa51b4e2
commit a245ea1743
Notes: sideshowbarker 2024-07-18 08:47:35 +09:00

View file

@ -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; }