1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:24:58 +00:00

AK: Support creating known short string literals at compile time

In cases where we know a string literal will fit in the short string
storage, we can do so at compile time without needing to handle error
propagation. If the provided string literal is too long, a compilation
error will be emitted due to the failed VERIFY statement being a non-
constant expression.
This commit is contained in:
Timothy Flynn 2023-01-20 07:20:01 -05:00 committed by Tim Flynn
parent e634778679
commit d48266a420
3 changed files with 45 additions and 16 deletions

View file

@ -169,11 +169,6 @@ String::String(NonnullRefPtr<Detail::StringData> data)
{
}
String::String(ShortString short_string)
: m_short_string(short_string)
{
}
String::String(String const& other)
: m_data(other.m_data)
{
@ -207,7 +202,7 @@ String& String::operator=(String const& other)
return *this;
}
String::~String()
void String::destroy_string()
{
if (!is_short_string())
m_data->unref();