WindowServer: Use early return to reduce nesting

This commit is contained in:
Shannon Booth 2020-02-11 20:33:38 +13:00 committed by Andreas Kling
commit 97508844dc
Notes: sideshowbarker 2024-07-19 09:27:18 +09:00

View file

@ -125,8 +125,11 @@ void Menu::redraw()
Window& Menu::ensure_menu_window()
{
if (m_menu_window)
return *m_menu_window;
int width = this->content_width();
if (!m_menu_window) {
Gfx::Point next_item_location(frame_thickness(), frame_thickness());
for (auto& item : m_items) {
int height = 0;
@ -151,7 +154,7 @@ Window& Menu::ensure_menu_window()
window->set_rect(0, 0, width, window_height);
m_menu_window = move(window);
draw();
}
return *m_menu_window;
}