From 0d543b604befa07d33b6c2e05b6a6f8d5d164018 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 11 Jun 2025 11:35:28 +0200 Subject: [PATCH] AK: Make more use of lazily calculated code point count in `Utf16View` In 0c93a07fb1a971f009af34f96d567919f0048165, a lazily calculated code point count was introduced but was not used in all places where we need that count. No functional changes. --- AK/Utf16View.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index 0bc49aba50d..824ad7acec0 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -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(); };