mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24: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:
parent
daf6d8173c
commit
aeee98b3a1
189 changed files with 597 additions and 652 deletions
|
@ -248,15 +248,15 @@ static int print_escaped(StringView name)
|
|||
|
||||
static DeprecatedString& hostname()
|
||||
{
|
||||
static DeprecatedString s_hostname;
|
||||
if (s_hostname.is_null()) {
|
||||
static Optional<DeprecatedString> s_hostname;
|
||||
if (!s_hostname.has_value()) {
|
||||
char buffer[HOST_NAME_MAX];
|
||||
if (gethostname(buffer, sizeof(buffer)) == 0)
|
||||
s_hostname = buffer;
|
||||
else
|
||||
s_hostname = "localhost";
|
||||
}
|
||||
return s_hostname;
|
||||
return *s_hostname;
|
||||
}
|
||||
|
||||
static size_t print_name(const struct stat& st, DeprecatedString const& name, Optional<StringView> path_for_link_resolution, StringView path_for_hyperlink)
|
||||
|
@ -470,7 +470,6 @@ static int do_file_system_object_long(DeprecatedString const& path)
|
|||
builder.append('/');
|
||||
builder.append(metadata.name);
|
||||
metadata.path = builder.to_deprecated_string();
|
||||
VERIFY(!metadata.path.is_null());
|
||||
int rc = lstat(metadata.path.characters(), &metadata.stat);
|
||||
if (rc < 0)
|
||||
perror("lstat");
|
||||
|
@ -595,7 +594,6 @@ int do_file_system_object_short(DeprecatedString const& path)
|
|||
builder.append('/');
|
||||
builder.append(metadata.name);
|
||||
metadata.path = builder.to_deprecated_string();
|
||||
VERIFY(!metadata.path.is_null());
|
||||
int rc = lstat(metadata.path.characters(), &metadata.stat);
|
||||
if (rc < 0)
|
||||
perror("lstat");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue