AK: Allow creating a StringView from an empty ReadonlyBytes
An empty Span (and so ReadonlyBytes) can be created with a null data pointer, which is no longer allowed for StringView. Detect that case and use an empty string instead.
This commit is contained in:
parent
5a7ef7d494
commit
7781f1d131
1 changed files with 1 additions and 2 deletions
|
|
@ -43,10 +43,9 @@ public:
|
|||
}
|
||||
|
||||
ALWAYS_INLINE StringView(ReadonlyBytes bytes)
|
||||
: m_characters(reinterpret_cast<char const*>(bytes.data()))
|
||||
: m_characters(bytes.is_empty() ? "" : reinterpret_cast<char const*>(bytes.data()))
|
||||
, m_length(bytes.size())
|
||||
{
|
||||
VERIFY(bytes.data() != nullptr);
|
||||
}
|
||||
|
||||
StringView(LIFETIME_BOUND ByteBuffer const&);
|
||||
|
|
|
|||
Loading…
Reference in a new issue