Skip to content

Commit 2d18210

Browse files
committed
fix: explicitly move all bool helper values, instead of copying unnecessary
1 parent 983b49d commit 2d18210

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

src/libs/core/helper/bool_wrapper.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ namespace helper {
2020

2121
BoolWrapper(bool value, const std::optional<T>& additional) : m_value{ value }, m_additional{ additional } { }
2222

23+
BoolWrapper(const BoolWrapper& other) = delete;
24+
25+
BoolWrapper& operator=(const BoolWrapper& other) = delete;
26+
27+
BoolWrapper(BoolWrapper&& other) noexcept
28+
: m_value{ other.m_value },
29+
m_additional{ std::move(other.m_additional) } {
30+
other.m_value = false;
31+
other.m_additional = std::nullopt;
32+
}
33+
34+
BoolWrapper& operator=(BoolWrapper&& other) noexcept = default;
35+
2336
const std::optional<T>& get_additional() const {
2437
return m_additional;
2538
}

src/scenes/recording_selector/recording_chooser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ui::Widget::EventHandleResult custom_ui::RecordingFileChooser::handle_event(
101101
) {
102102
//TODO(Totto): this double nested component can't correctly detect focus changes (since the checking for a focus change only occurs at one level deep)
103103
//TODO(Totto): allow horizontal RIGHT <-> LEFT focus change on horizontal focus_layouts
104-
if (const auto handled = m_main_grid.handle_event(input_manager, event); handled) {
104+
if (auto handled = m_main_grid.handle_event(input_manager, event); handled) {
105105
return handled;
106106
}
107107

src/scenes/settings_menu/color_setting_row.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ ui::Widget::EventHandleResult custom_ui::ColorSettingRow::handle_event(
179179
const std::shared_ptr<input::InputManager>& input_manager,
180180
const SDL_Event& event
181181
) {
182-
const auto result = m_main_layout.handle_event(input_manager, event);
182+
auto result = m_main_layout.handle_event(input_manager, event);
183183
if (const auto additional = result.get_additional(); additional.has_value()) {
184184
if (std::get<0>(additional.value()) == ui::EventHandleType::RequestAction) {
185185
return {

src/ui/layouts/focus_layout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ui::Widget::EventHandleResult ui::FocusLayout::handle_focus_change_button_events
7070
const SDL_Event& event
7171
) {
7272

73-
Widget::EventHandleResult handled = false;
73+
ui::Widget::EventHandleResult handled = false;
7474

7575
const auto navigation_action = input_manager->get_navigation_event(event);
7676

@@ -96,7 +96,7 @@ ui::Widget::EventHandleResult ui::FocusLayout::handle_focus_change_events(
9696
return false;
9797
}
9898

99-
Widget::EventHandleResult handled = false;
99+
ui::Widget::EventHandleResult handled{ false };
100100

101101
if (m_focus_id.has_value()) {
102102
const auto& widget = m_widgets.at(focusable_index_by_id(m_focus_id.value()));

src/ui/layouts/scroll_layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ ui::Widget::EventHandleResult ui::ScrollLayout::handle_focus_change_events(
240240
return false;
241241
}
242242

243-
Widget::EventHandleResult handled = false;
243+
Widget::EventHandleResult handled{ false };
244244

245245

246246
if (m_focus_id.has_value()) {

0 commit comments

Comments
 (0)