Skip to content

Commit

Permalink
optimisation: menu_item == menu_line is always true
Browse files Browse the repository at this point in the history
The if statement is checked in lcd_sdcard_menu()

so checking it again these functions is
redundant since it's always going to be true.

Tested on MK3S+

Change in memory:
Flash: -22 bytes
SRAM: 0 bytes
  • Loading branch information
gudnimg committed Aug 20, 2023
1 parent 2a71e68 commit cabc441
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,40 +277,34 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* lon

static void menu_item_sddir(const char* str_fn, char* str_fnl)
{
if (menu_item == menu_line)
if (lcd_draw_update)
{
if (lcd_draw_update)
{
lcd_implementation_drawmenu_sddirectory(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
lcd_update_enabled = false;
menu_action_sddirectory(str_fn);
lcd_update_enabled = true;
menu_item_ret();
return;
}
lcd_implementation_drawmenu_sddirectory(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
lcd_update_enabled = false;
menu_action_sddirectory(str_fn);
lcd_update_enabled = true;
menu_item_ret();
return;
}
menu_item++;
}

static void menu_item_sdfile(const char* str_fn, char* str_fnl)
{
if (menu_item == menu_line)
if (lcd_draw_update)
{
if (lcd_draw_update)
{
lcd_implementation_drawmenu_sdfile(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
lcd_update_enabled = false;
menu_action_sdfile(str_fn);
lcd_update_enabled = true;
menu_item_ret();
return;
}
lcd_implementation_drawmenu_sdfile(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
lcd_update_enabled = false;
menu_action_sdfile(str_fn);
lcd_update_enabled = true;
menu_item_ret();
return;
}
menu_item++;
}
Expand Down

0 comments on commit cabc441

Please sign in to comment.