summaryrefslogtreecommitdiff
path: root/Userland/Applications/KeyboardMapper
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-02-09 13:26:53 -0500
committerLinus Groh <mail@linusgroh.de>2023-02-10 09:08:52 +0000
commit4a916cd3796cef0ef10374fcf9a602c96e226e6c (patch)
tree8794ceaaad624514796fba84e0a79e3a407079fc /Userland/Applications/KeyboardMapper
parent52687814ea8f80ea2a0f38af0902e4223a0a76b9 (diff)
downloadserenity-4a916cd3796cef0ef10374fcf9a602c96e226e6c.zip
Everywhere: Remove needless copies of Error / ErrorOr instances
Either take the underlying objects with release_* methods or move() the instances around.
Diffstat (limited to 'Userland/Applications/KeyboardMapper')
-rw-r--r--Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp5
-rw-r--r--Userland/Applications/KeyboardMapper/main.cpp15
2 files changed, 8 insertions, 12 deletions
diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
index 099d3179d7..9d97082a3b 100644
--- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
+++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
@@ -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;
diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp
index 77ef321792..015e0270a2 100644
--- a/Userland/Applications/KeyboardMapper/main.cpp
+++ b/Userland/Applications/KeyboardMapper/main.cpp
@@ -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(