From dfb4b603e4fd41fef0122ada466f97194d77c6f5 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sun, 4 Sep 2022 07:30:21 +0200 Subject: [PATCH] Get rid of superfluous wrapper function file_list_get_at_offset --- libretro-common/include/lists/file_list.h | 4 -- libretro-common/lists/file_list.c | 17 ------ menu/cbs/menu_cbs_ok.c | 11 ++-- menu/menu_displaylist.c | 3 +- menu/menu_driver.c | 67 ++++++++++++++--------- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/libretro-common/include/lists/file_list.h b/libretro-common/include/lists/file_list.h index 3dbc053a1f..5969d6800f 100644 --- a/libretro-common/include/lists/file_list.h +++ b/libretro-common/include/lists/file_list.h @@ -104,10 +104,6 @@ size_t file_list_get_size(const file_list_t *list); size_t file_list_get_directory_ptr(const file_list_t *list); -void file_list_get_at_offset(const file_list_t *list, size_t index, - const char **path, const char **label, - unsigned *type, size_t *entry_idx); - void file_list_free_userdata(const file_list_t *list, size_t index); void file_list_free_actiondata(const file_list_t *list, size_t idx); diff --git a/libretro-common/lists/file_list.c b/libretro-common/lists/file_list.c index 846f484c44..836db97523 100644 --- a/libretro-common/lists/file_list.c +++ b/libretro-common/lists/file_list.c @@ -362,23 +362,6 @@ void file_list_free_userdata(const file_list_t *list, size_t idx) list->list[idx].userdata = NULL; } -void file_list_get_at_offset(const file_list_t *list, size_t idx, - const char **path, const char **label, unsigned *file_type, - size_t *entry_idx) -{ - if (!list) - return; - - if (path) - *path = list->list[idx].path; - if (label) - *label = list->list[idx].label; - if (file_type) - *file_type = list->list[idx].type; - if (entry_idx) - *entry_idx = list->list[idx].entry_idx; -} - bool file_list_search(const file_list_t *list, const char *needle, size_t *idx) { size_t i; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e7a567651d..822035a7a9 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2326,7 +2326,10 @@ static int action_ok_file_load(const char *path, } if (menu_stack && menu_stack->size) - file_list_get_at_offset(menu_stack, menu_stack->size - 1, &menu_path, &menu_label, NULL, NULL); + { + menu_path = menu_stack->list[menu_stack->size - 1].path; + menu_label = menu_stack->list[menu_stack->size - 1].label; + } if (!string_is_empty(menu_label)) setting = menu_setting_find(menu_label); @@ -3928,7 +3931,7 @@ static int action_ok_file_load_ffmpeg(const char *path, file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); if (menu_stack && menu_stack->size) - file_list_get_at_offset(menu_stack, menu_stack->size - 1, &menu_path, NULL, NULL, NULL); + menu_path = menu_stack->list[menu_stack->size - 1].path; if (string_is_empty(menu_path)) return -1; @@ -4370,7 +4373,7 @@ static int action_ok_file_load_imageviewer(const char *path, file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); if (menu_stack && menu_stack->size) - file_list_get_at_offset(menu_stack, menu_stack->size - 1, &menu_path, NULL, NULL, NULL); + menu_path = menu_stack->list[menu_stack->size - 1].path; if (!string_is_empty(menu_path)) fill_pathname_join_special(fullpath, menu_path, path, @@ -5334,7 +5337,7 @@ int action_ok_close_content(const char *path, const char *label, unsigned type, list = MENU_LIST_GET(menu_st->entries.list, 0); if (list && (list->size > 1)) { - file_list_get_at_offset(list, list->size - 2, NULL, &parent_label, NULL, NULL); + parent_label = list->list[list->size - 2].label; if (string_is_equal(parent_label, msg_hash_to_str(MENU_ENUM_LABEL_CONTENTLESS_CORES_TAB)) || string_is_equal(parent_label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_CONTENTLESS_CORES_LIST))) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e6761f79cf..10712b42e2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4699,8 +4699,7 @@ static unsigned menu_displaylist_parse_content_information( list = MENU_LIST_GET(menu_st->entries.list, 0); if (list && (list->size > 2)) { - file_list_get_at_offset(list, list->size - 3, NULL, - &origin_label, NULL, NULL); + origin_label = list->list[list->size - 3].label; if (string_is_equal(origin_label, msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU)) || string_is_equal(origin_label, msg_hash_to_str(MENU_ENUM_LABEL_CONTENTLESS_CORES_TAB)) || diff --git a/menu/menu_driver.c b/menu/menu_driver.c index cf1a8b34ad..8d278bf357 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -399,8 +399,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, entry->checked = cbs->checked; if (menu_stack && menu_stack->size) - file_list_get_at_offset(menu_stack, menu_stack->size - 1, - NULL, &label, NULL, NULL); + label = menu_stack->list[menu_stack->size - 1].label; if (entry->rich_label_enabled && cbs->action_label) { @@ -1110,8 +1109,11 @@ int menu_entries_get_title(char *s, size_t len) } if (list && list->size) - file_list_get_at_offset(list, list->size - 1, - &path, &label, &menu_type, NULL); + { + path = list->list[list->size - 1].path; + label = list->list[list->size - 1].label; + menu_type = list->list[list->size - 1].type; + } /* Show playlist entry instead of "Quick Menu" */ if (string_is_equal(label, "deferred_rpl_entry_actions")) @@ -1154,8 +1156,7 @@ void menu_input_pointer_close_messagebox(struct menu_state *menu_st) /* Determine whether this is a help or info * message box */ if (list && list->size) - file_list_get_at_offset(list, list->size - 1, - NULL, &label, NULL, NULL); + label = list->list[list->size - 1].label; /* Pop stack, if required */ if (menu_should_pop_stack(label)) @@ -1336,17 +1337,18 @@ void menu_list_flush_stack( size_t idx, 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); menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); menu_contentless_cores_flush_runtime(); if (menu_list && menu_list->size) - file_list_get_at_offset(menu_list, menu_list->size - 1, &path, &label, &type, &entry_idx); + { + label = menu_list->list[menu_list->size - 1].label; + type = menu_list->list[menu_list->size - 1].type; + } while (menu_list_flush_stack_type( needle, label, type, final_type) != 0) @@ -1371,7 +1373,10 @@ void menu_list_flush_stack( menu_list = MENU_LIST_GET(list, (unsigned)idx); if (menu_list && menu_list->size) - file_list_get_at_offset(menu_list, menu_list->size - 1, &path, &label, &type, &entry_idx); + { + label = menu_list->list[menu_list->size - 1].label; + type = menu_list->list[menu_list->size - 1].type; + } } } @@ -2407,7 +2412,11 @@ bool menu_driver_displaylist_push( menu_displaylist_info_init(&info); if (list && list->size) - file_list_get_at_offset(list, list->size - 1, &path, &label, &type, NULL); + { + path = list->list[list->size - 1].path; + label = list->list[list->size - 1].label; + type = list->list[list->size - 1].type; + } if (cbs) enum_idx = cbs->enum_idx; @@ -2520,7 +2529,7 @@ void menu_cbs_init( #endif if (menu_list && menu_list->size) - file_list_get_at_offset(menu_list, menu_list->size - 1, NULL, &menu_label, NULL, NULL); + menu_label = menu_list->list[menu_list->size - 1].label; if (!label || !menu_label) return; @@ -4141,7 +4150,16 @@ void menu_entries_get_last_stack(const char **path, const char **label, list = MENU_LIST_GET(menu_st->entries.list, 0); if (list && list->size) - file_list_get_at_offset(list, list->size - 1, path, label, file_type, entry_idx); + { + if (path) + *path = list->list[list->size - 1].path; + if (label) + *label = list->list[list->size - 1].label; + if (file_type) + *file_type = list->list[list->size - 1].type; + if (entry_idx) + *entry_idx = list->list[list->size - 1].entry_idx; + } if (enum_idx) { @@ -4218,8 +4236,10 @@ void menu_input_search_cb(void *userdata, const char *str) * viewing a menu list with 'search * filter' support */ if (list && list->size) - file_list_get_at_offset(list, list->size - 1, - NULL, &label, &type, NULL); + { + label = list->list[list->size - 1].label; + type = list->list[list->size - 1].type; + } /* Do not apply search filter if string * consists of a single Latin alphabet @@ -4373,9 +4393,7 @@ bool menu_entries_append( file_list_append(list, path, label, type, directory_ptr, entry_idx); if (mlist && mlist->size) - file_list_get_at_offset(mlist, mlist->size - 1, - &menu_path, NULL, NULL, NULL); - + menu_path = mlist->list[mlist->size - 1].path; idx = list->size - 1; list_info.fullpath = NULL; @@ -4468,8 +4486,7 @@ void menu_entries_prepend(file_list_t *list, file_list_insert(list, path, label, type, directory_ptr, entry_idx, 0); if (mlist && mlist->size) - file_list_get_at_offset(mlist, mlist->size -1, - &menu_path, NULL, NULL, NULL); + menu_path = mlist->list[mlist->size - 1].path; list_info.fullpath = NULL; @@ -7360,13 +7377,12 @@ static int generic_menu_iterate( unsigned accessibility_narrator_speech_speed = settings->uints.accessibility_narrator_speech_speed; #endif enum action_iterate_type iterate_type; - unsigned file_type = 0; int ret = 0; const char *label = NULL; file_list_t *list = MENU_LIST_GET(menu_st->entries.list, 0); if (list && list->size) - file_list_get_at_offset(list, list->size - 1, NULL, &label, &file_type, NULL); + label = list->list[list->size - 1].label; menu->menu_state_msg[0] = '\0'; @@ -8053,11 +8069,8 @@ int generic_menu_entry_action( * find a known reference point */ while (menu_stack && (menu_stack->size >= stack_offset)) { - const char *parent_label = NULL; - - file_list_get_at_offset(menu_stack, - menu_stack->size - stack_offset, - NULL, &parent_label, NULL, NULL); + const char *parent_label = menu_stack->list[ + menu_stack->size - stack_offset].label; if (string_is_empty(parent_label)) continue;