mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
AK: Make more use of lazily calculated code point count in Utf16View
In 0c93a07fb1
, a lazily calculated code
point count was introduced but was not used in all places where we need
that count. No functional changes.
This commit is contained in:
parent
9126507dc6
commit
0d543b604b
Notes:
github-actions[bot]
2025-06-13 13:10:34 +00:00
Author: https://github.com/gmta
Commit: 0d543b604b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5067
Reviewed-by: https://github.com/tcl3
Reviewed-by: https://github.com/trflynn89
1 changed files with 3 additions and 3 deletions
|
@ -204,7 +204,7 @@ u32 Utf16View::code_point_at(size_t index) const
|
|||
|
||||
size_t Utf16View::code_point_offset_of(size_t code_unit_offset) const
|
||||
{
|
||||
if (m_length_in_code_points == m_code_units.size()) // Fast path: all code points are one code unit.
|
||||
if (length_in_code_points() == length_in_code_units()) // Fast path: all code points are one code unit.
|
||||
return code_unit_offset;
|
||||
|
||||
size_t code_point_offset = 0;
|
||||
|
@ -222,7 +222,7 @@ size_t Utf16View::code_point_offset_of(size_t code_unit_offset) const
|
|||
|
||||
size_t Utf16View::code_unit_offset_of(size_t code_point_offset) const
|
||||
{
|
||||
if (m_length_in_code_points == m_code_units.size()) // Fast path: all code points are one code unit.
|
||||
if (length_in_code_points() == length_in_code_units()) // Fast path: all code points are one code unit.
|
||||
return code_point_offset;
|
||||
|
||||
size_t code_unit_offset = 0;
|
||||
|
@ -259,7 +259,7 @@ Utf16View Utf16View::unicode_substring_view(size_t code_point_offset, size_t cod
|
|||
if (code_point_length == 0)
|
||||
return {};
|
||||
|
||||
if (m_length_in_code_points == m_code_units.size()) // Fast path: all code points are one code unit.
|
||||
if (length_in_code_points() == length_in_code_units()) // Fast path: all code points are one code unit.
|
||||
return substring_view(code_point_offset, code_point_length);
|
||||
|
||||
auto code_unit_offset_of = [&](Utf16CodePointIterator const& it) { return it.m_ptr - begin_ptr(); };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue