mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
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:
parent
55fa51b4e2
commit
a245ea1743
Notes:
sideshowbarker
2024-07-18 08:47:35 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/a245ea1743f Pull-request: https://github.com/SerenityOS/serenity/pull/8847 Reviewed-by: https://github.com/MaxWipfli Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/trflynn89
1 changed files with 8 additions and 0 deletions
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue