mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Change String's default constructor to be constant
This allows creating expressions such as: constexpr Array<String, 10> {};
This commit is contained in:
parent
34574c5ee8
commit
8aca8e82cb
Notes:
sideshowbarker
2024-07-17 06:51:40 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8aca8e82cb Pull-request: https://github.com/SerenityOS/serenity/pull/17122 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/nico
2 changed files with 4 additions and 7 deletions
|
@ -208,12 +208,6 @@ void String::destroy_string()
|
|||
m_data->unref();
|
||||
}
|
||||
|
||||
String::String()
|
||||
{
|
||||
// This is an empty string, it's always short and zero-length.
|
||||
m_short_string.byte_count_and_short_string_flag = SHORT_STRING_FLAG;
|
||||
}
|
||||
|
||||
ErrorOr<String> String::from_utf8(StringView view)
|
||||
{
|
||||
if (view.length() <= MAX_SHORT_STRING_BYTE_COUNT) {
|
||||
|
|
|
@ -52,7 +52,10 @@ public:
|
|||
}
|
||||
|
||||
// Creates an empty (zero-length) String.
|
||||
String();
|
||||
constexpr String()
|
||||
: String(ShortString { SHORT_STRING_FLAG, {} })
|
||||
{
|
||||
}
|
||||
|
||||
// Creates a new String from a sequence of UTF-8 encoded code points.
|
||||
static ErrorOr<String> from_utf8(StringView);
|
||||
|
|
Loading…
Reference in a new issue