AK: Shrink Utf16View

Use a sentinel value instead of Optional for the cached length in code
points, shrinking Utf16View from 32 to 24 bytes.
This commit is contained in:
Andreas Kling 2025-04-15 18:08:26 +02:00 committed by Andreas Kling
commit 0c93a07fb1
Notes: github-actions[bot] 2025-04-16 08:05:52 +00:00
2 changed files with 3 additions and 3 deletions

View file

@ -177,9 +177,9 @@ ErrorOr<String> Utf16View::to_utf8(AllowInvalidCodeUnits allow_invalid_code_unit
size_t Utf16View::length_in_code_points() const
{
if (!m_length_in_code_points.has_value())
if (m_length_in_code_points == NumericLimits<size_t>::max())
m_length_in_code_points = calculate_length_in_code_points();
return *m_length_in_code_points;
return m_length_in_code_points;
}
u16 Utf16View::code_unit_at(size_t index) const