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:
parent
e634778679
commit
d48266a420
3 changed files with 45 additions and 16 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue