Refactor menu_list_pop_stack_by_needle

This commit is contained in:
twinaphex 2015-06-14 15:59:06 +02:00
parent 1f93ec63b4
commit b5333cdbab
1 changed files with 5 additions and 5 deletions

View File

@ -296,29 +296,29 @@ void menu_list_pop_stack(menu_list_t *list)
void menu_list_pop_stack_by_needle(menu_list_t *list, void menu_list_pop_stack_by_needle(menu_list_t *list,
const char *needle) const char *needle)
{ {
uint32_t label_hash; uint32_t needle_hash, label_hash;
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
unsigned type = 0; unsigned type = 0;
size_t entry_idx = 0; size_t entry_idx = 0;
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr();
uint32_t needle_hash = djb2_calculate(needle);
if (!menu || !list) if (!menu || !list)
return; return;
menu_set_refresh(); menu_set_refresh();
menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx); menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
needle_hash = djb2_calculate(needle);
label_hash = djb2_calculate(label); label_hash = djb2_calculate(label);
(void)label_hash;
while (!strcmp(needle, label)) while (needle_hash == label_hash)
{ {
menu_list_pop(list->menu_stack, &nav->selection_ptr); menu_list_pop(list->menu_stack, &nav->selection_ptr);
menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx); menu_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
label_hash = djb2_calculate(label);
needle_hash = djb2_calculate(needle);
} }
} }