1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:27:35 +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

@ -141,7 +141,7 @@ static ErrorOr<String> display_name_from_edid(EDID::Parser const& edid)
auto product_name = edid.display_product_name();
auto build_manufacturer_product_name = [&]() -> ErrorOr<String> {
if (product_name.is_null() || product_name.is_empty())
if (product_name.is_empty())
return TRY(String::from_deprecated_string(manufacturer_name));
return String::formatted("{} {}", manufacturer_name, product_name);
};

View file

@ -319,7 +319,7 @@ void MailWidget::selected_mailbox(GUI::ModelIndex const& index)
DeprecatedString date = internal_date.to_deprecated_string();
DeprecatedString subject = envelope.subject.value_or("(No subject)");
if (subject.contains("=?"sv) && subject.contains("?="sv)) {
subject = MUST(IMAP::decode_rfc2047_encoded_words(subject));
subject = MUST(IMAP::decode_rfc2047_encoded_words(subject)).span();
}
StringBuilder sender_builder;
@ -491,9 +491,9 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index)
} else if (selected_alternative_encoding.equals_ignoring_ascii_case("base64"sv)) {
auto decoded_base64 = decode_base64(encoded_data);
if (!decoded_base64.is_error())
decoded_data = decoded_base64.release_value();
decoded_data = decoded_base64.release_value().span();
} else if (selected_alternative_encoding.equals_ignoring_ascii_case("quoted-printable"sv)) {
decoded_data = IMAP::decode_quoted_printable(encoded_data).release_value_but_fixme_should_propagate_errors();
decoded_data = IMAP::decode_quoted_printable(encoded_data).release_value_but_fixme_should_propagate_errors().span();
} else {
dbgln("Mail: Unimplemented decoder for encoding: {}", selected_alternative_encoding);
GUI::MessageBox::show(window(), DeprecatedString::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported"sv, GUI::MessageBox::Type::Information);

View file

@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
TRY(Core::System::unveil("/tmp/portal/window", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
DeprecatedString adapter;
StringView adapter;
Core::ArgsParser parser;
parser.add_positional_argument(adapter, "Adapter to display settings for", "adapter", Core::ArgsParser::Required::No);

View file

@ -26,7 +26,7 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path)
NonnullOwnPtr<M3UParser> M3UParser::from_memory(DeprecatedString const& m3u_contents, bool utf8)
{
auto parser = make<M3UParser>();
VERIFY(!m3u_contents.is_null() && !m3u_contents.is_empty() && !m3u_contents.is_whitespace());
VERIFY(!m3u_contents.is_empty() && !m3u_contents.is_whitespace());
parser->m_m3u_raw_data = m3u_contents;
parser->m_use_utf8 = utf8;
return parser;

View file

@ -40,9 +40,6 @@ Player::Player(Audio::ConnectionToServer& audio_client_connection)
void Player::play_file_path(DeprecatedString const& path)
{
if (path.is_null())
return;
if (!FileSystem::exists(path)) {
audio_load_error(path, "File does not exist"sv);
return;

View file

@ -22,7 +22,7 @@ namespace Spreadsheet {
void SpreadsheetView::EditingDelegate::set_value(GUI::Variant const& value, GUI::ModelEditingDelegate::SelectionBehavior selection_behavior)
{
if (value.as_string().is_null()) {
if (!value.is_valid()) {
StringModelEditingDelegate::set_value("", selection_behavior);
commit();
return;

View file

@ -74,7 +74,7 @@ void MemoryStatsWidget::set_graph_widget(GraphWidget& graph)
void MemoryStatsWidget::set_graph_widget_via_name(DeprecatedString name)
{
m_graph_widget_name = move(name);
if (!m_graph_widget_name.is_null()) {
if (!m_graph_widget_name.is_empty()) {
// FIXME: We assume here that the graph widget is a sibling or descendant of a sibling. This prevents more complex hierarchies.
auto* maybe_graph = parent_widget()->find_descendant_of_type_named<GraphWidget>(m_graph_widget_name);
if (maybe_graph) {

View file

@ -279,7 +279,7 @@ MainWidget::MainWidget()
m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
auto extension = m_extension;
if (extension.is_null() && m_editor->syntax_highlighter())
if (extension.is_empty() && m_editor->syntax_highlighter())
extension = Syntax::common_language_extension(m_editor->syntax_highlighter()->language());
auto response = FileSystemAccessClient::Client::the().save_file(window(), m_name, extension);