AK: Add Utf8View::iterator_at_byte_offset_without_validation()

Unlike iterator_at_byte_offset(), this function assumes the provided
byte offset is a valid offset into the UTF-8 character stream.

This avoids walking the stream from the start.
This commit is contained in:
Andreas Kling 2022-11-24 14:57:20 +01:00 committed by Linus Groh
commit e7ba03ddd1
Notes: sideshowbarker 2024-07-17 04:09:57 +09:00
2 changed files with 7 additions and 0 deletions

View file

@ -80,6 +80,8 @@ public:
Utf8CodePointIterator end() const { return { end_ptr(), 0 }; }
Utf8CodePointIterator iterator_at_byte_offset(size_t) const;
Utf8CodePointIterator iterator_at_byte_offset_without_validation(size_t) const;
unsigned char const* bytes() const { return begin_ptr(); }
size_t byte_length() const { return m_string.length(); }
size_t byte_offset_of(Utf8CodePointIterator const&) const;