AK: Don't return a null Utf32View when a zero-length one is requested

There is still an offset to consider, a zero-length view is very
different from a nonexistent string :P

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
Ali Mohammad Pur 2021-07-18 00:19:16 +04:30 committed by Ali Mohammad Pur
parent 2f754013a1
commit 0060fa48d4

View file

@ -94,9 +94,7 @@ public:
Utf32View substring_view(size_t offset, size_t length) const
{
if (length == 0)
return {};
VERIFY(offset < m_length);
VERIFY(offset <= m_length);
VERIFY(!Checked<size_t>::addition_would_overflow(offset, length));
VERIFY((offset + length) <= m_length);
return Utf32View(m_code_points + offset, length);