1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:57:34 +00:00

AK: Add String constructor from ReadonlyBytes.

This commit is contained in:
asynts 2020-08-05 10:37:34 +02:00 committed by Andreas Kling
parent 42b4880653
commit 75cde94c6a
3 changed files with 23 additions and 0 deletions

View file

@ -83,6 +83,11 @@ public:
{
}
explicit String(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp)
: m_impl(StringImpl::create(bytes, shouldChomp))
{
}
String(const StringImpl& impl)
: m_impl(const_cast<StringImpl&>(impl))
{
@ -196,6 +201,18 @@ public:
return *this;
}
String& operator=(std::nullptr_t)
{
m_impl = nullptr;
return *this;
}
String& operator=(ReadonlyBytes bytes)
{
m_impl = StringImpl::create(bytes);
return *this;
}
u32 hash() const
{
if (!m_impl)