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

AK+Everywhere: Remove the null state of DeprecatedString

This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
This commit is contained in:
Ali Mohammad Pur 2023-10-10 15:00:58 +03:30 committed by Ali Mohammad Pur
parent daf6d8173c
commit aeee98b3a1
189 changed files with 597 additions and 652 deletions

View file

@ -47,9 +47,6 @@ NonnullRefPtr<StringImpl const> StringImpl::create_uninitialized(size_t length,
RefPtr<StringImpl const> StringImpl::create(char const* cstring, size_t length, ShouldChomp should_chomp)
{
if (!cstring)
return nullptr;
if (should_chomp) {
while (length) {
char last_ch = cstring[length - 1];
@ -72,10 +69,7 @@ RefPtr<StringImpl const> StringImpl::create(char const* cstring, size_t length,
RefPtr<StringImpl const> StringImpl::create(char const* cstring, ShouldChomp shouldChomp)
{
if (!cstring)
return nullptr;
if (!*cstring)
if (!cstring || !*cstring)
return the_empty_stringimpl();
return create(cstring, strlen(cstring), shouldChomp);
@ -88,8 +82,6 @@ RefPtr<StringImpl const> StringImpl::create(ReadonlyBytes bytes, ShouldChomp sho
RefPtr<StringImpl const> StringImpl::create_lowercased(char const* cstring, size_t length)
{
if (!cstring)
return nullptr;
if (!length)
return the_empty_stringimpl();
char* buffer;
@ -101,8 +93,6 @@ RefPtr<StringImpl const> StringImpl::create_lowercased(char const* cstring, size
RefPtr<StringImpl const> StringImpl::create_uppercased(char const* cstring, size_t length)
{
if (!cstring)
return nullptr;
if (!length)
return the_empty_stringimpl();
char* buffer;