mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +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
Notes:
sideshowbarker
2024-07-17 02:23:25 +09:00
Author: https://github.com/trflynn89
Commit: d48266a420
Pull-request: https://github.com/SerenityOS/serenity/pull/17102
Reviewed-by: https://github.com/alimpfard ✅
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/linusg ✅
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