1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:18:12 +00:00

Everywhere: Remove needless copies of Error / ErrorOr instances

Either take the underlying objects with release_* methods or move() the
instances around.
This commit is contained in:
Timothy Flynn 2023-02-09 13:26:53 -05:00 committed by Linus Groh
parent 52687814ea
commit 4a916cd379
28 changed files with 69 additions and 77 deletions

View file

@ -27,9 +27,8 @@ bool KeyboardMapperWidget::request_close()
return true;
auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_filename);
if (result == GUI::MessageBox::ExecResult::Yes) {
ErrorOr<void> error_or = save();
if (error_or.is_error())
show_error_to_user(error_or.error());
if (auto error_or = save(); error_or.is_error())
show_error_to_user(error_or.release_error());
if (!window()->is_modified())
return true;

View file

@ -54,16 +54,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!path.has_value())
return;
ErrorOr<void> error_or = keyboard_mapper_widget->load_map_from_file(path.value());
if (error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.error());
if (auto error_or = keyboard_mapper_widget->load_map_from_file(path.value()); error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.release_error());
});
auto save_action = GUI::CommonActions::make_save_action(
[&](auto&) {
ErrorOr<void> error_or = keyboard_mapper_widget->save();
if (error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.error());
if (auto error_or = keyboard_mapper_widget->save(); error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.release_error());
});
auto save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) {
@ -72,9 +70,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!save_path.has_value())
return;
ErrorOr<void> error_or = keyboard_mapper_widget->save_to_file(save_path.value());
if (error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.error());
if (auto error_or = keyboard_mapper_widget->save_to_file(save_path.value()); error_or.is_error())
keyboard_mapper_widget->show_error_to_user(error_or.release_error());
});
auto quit_action = GUI::CommonActions::make_quit_action(