Cleanups - don't call MENU_ENTRIES_CTL_SET_REFRESH in a loop - set it

once outside
This commit is contained in:
twinaphex 2021-03-11 22:17:38 +01:00
parent 4dc70a6e9c
commit ee06ddfbc0

View File

@ -2916,11 +2916,7 @@ error:
return NULL;
}
static int menu_list_flush_stack_type(const char *needle, const char *label,
unsigned type, unsigned final_type)
{
return needle ? !string_is_equal(needle, label) : (type != final_type);
}
#define MENU_LIST_FLUSH_STACK_TYPE(needle, label, type, final_type) (needle ? !string_is_equal(needle, label) : (type != final_type))
static bool menu_list_pop_stack(
const menu_ctx_driver_t *menu_driver_ctx,
@ -2956,26 +2952,24 @@ static void menu_list_flush_stack(
void *menu_userdata,
struct menu_state *menu_st,
menu_list_t *list,
size_t idx, const char *needle, unsigned final_type)
const char *needle, unsigned final_type)
{
bool refresh = false;
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
size_t entry_idx = 0;
file_list_t *menu_list = MENU_LIST_GET(list, (unsigned)idx);
file_list_t *menu_list = MENU_LIST_GET(list, 0);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
if (menu_list && menu_list->size)
file_list_get_at_offset(menu_list, menu_list->size - 1, &path, &label, &type, &entry_idx);
file_list_get_at_offset(menu_list, menu_list->size - 1, NULL,
&label, &type, NULL);
while (menu_list_flush_stack_type(
while (MENU_LIST_FLUSH_STACK_TYPE(
needle, label, type, final_type) != 0)
{
bool refresh = false;
size_t new_selection_ptr = menu_st->selection_ptr;
bool wont_pop_stack = (MENU_LIST_GET_STACK_SIZE(list, idx) <= 1);
size_t new_selection_ptr = 0;
bool wont_pop_stack = (MENU_LIST_GET_STACK_SIZE(list, 0) <= 1);
if (wont_pop_stack)
break;
@ -2985,15 +2979,14 @@ static void menu_list_flush_stack(
menu_list_pop_stack(menu_driver_ctx,
menu_userdata,
list, idx, &new_selection_ptr);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
list, 0, &new_selection_ptr);
menu_st->selection_ptr = new_selection_ptr;
menu_list = MENU_LIST_GET(list, (unsigned)idx);
menu_list = MENU_LIST_GET(list, 0);
if (menu_list && menu_list->size)
file_list_get_at_offset(menu_list, menu_list->size - 1, &path, &label, &type, &entry_idx);
file_list_get_at_offset(menu_list, menu_list->size - 1, NULL,
&label, &type, NULL);
}
}
@ -3494,7 +3487,9 @@ void menu_entries_flush_stack(const char *needle, unsigned final_type)
p_rarch->menu_driver_ctx,
p_rarch->menu_userdata,
menu_st,
menu_list, 0, needle, final_type);
menu_list,
needle,
final_type);
}
void menu_entries_pop_stack(size_t *ptr, size_t idx, bool animate)