Browse Source

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>
Ali Mohammad Pur 4 years ago
parent
commit
0060fa48d4
1 changed files with 1 additions and 3 deletions
  1. 1 3
      AK/Utf32View.h

+ 1 - 3
AK/Utf32View.h

@@ -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);