From a2031608e735bd3158d3f0defc6522be3a1f22ea Mon Sep 17 00:00:00 2001 From: twinaphex <libretro@gmail.com> Date: Wed, 10 Mar 2021 08:36:59 +0100 Subject: [PATCH] Don't use file_list_get_at_offset - access members directly --- menu/cbs/menu_cbs_get_value.c | 39 +++++++++------------------- menu/cbs/menu_cbs_sublabel.c | 5 +--- menu/drivers/ozone/ozone_sidebar.c | 35 ++++++++----------------- menu/drivers/stripes.c | 38 ++++++++++----------------- menu/drivers/xmb.c | 33 ++++++++---------------- menu/menu_displaylist.c | 6 ++--- retroarch.c | 41 +++++++++++++++--------------- 7 files changed, 71 insertions(+), 126 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 59de32dc3d..6ddff51719 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -411,14 +411,11 @@ static void menu_action_setting_disp_set_label_menu_file_core( const char *path, char *s2, size_t len2) { - const char *alt = NULL; - strcpy_literal(s, "(CORE)"); - - file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL); - alt = list->list[i].alt + const char *alt = list->list[i].alt ? list->list[i].alt : list->list[i].path; - *w = (unsigned)strlen(s); + strcpy_literal(s, "(CORE)"); + *w = (unsigned)strlen(s); if (alt) strlcpy(s2, alt, len2); } @@ -434,15 +431,11 @@ static void menu_action_setting_disp_set_label_core_updater_entry( { core_updater_list_t *core_list = core_updater_list_get_cached(); const core_updater_list_entry_t *entry = NULL; - const char *alt = NULL; - - *s = '\0'; - *w = 0; - - file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL); - alt = list->list[i].alt + const char *alt = list->list[i].alt ? list->list[i].alt : list->list[i].path; + *s = '\0'; + *w = 0; if (alt) strlcpy(s2, alt, len2); @@ -487,16 +480,12 @@ static void menu_action_setting_disp_set_label_core_manager_entry( const char *path, char *s2, size_t len2) { - const char *alt = NULL; core_info_ctx_find_t core_info; - - *s = '\0'; - *w = 0; - - file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL); - alt = list->list[i].alt + const char *alt = list->list[i].alt ? list->list[i].alt : list->list[i].path; + *s = '\0'; + *w = 0; if (alt) strlcpy(s2, alt, len2); @@ -524,16 +513,12 @@ static void menu_action_setting_disp_set_label_core_lock( const char *path, char *s2, size_t len2) { - const char *alt = NULL; core_info_ctx_find_t core_info; - - *s = '\0'; - *w = 0; - - file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL); - alt = list->list[i].alt + const char *alt = list->list[i].alt ? list->list[i].alt : list->list[i].path; + *s = '\0'; + *w = 0; if (alt) strlcpy(s2, alt, len2); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 536c5d07d8..5d8d7f1a1e 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -1469,11 +1469,8 @@ static int action_bind_sublabel_core_backup_entry( const char *label, const char *path, char *s, size_t len) { - const char *crc = NULL; - /* crc is entered as 'alt' text */ - file_list_get_at_offset(list, i, NULL, NULL, NULL, NULL); - crc = list->list[i].alt + const char *crc = list->list[i].alt ? list->list[i].alt : list->list[i].path; diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index e3f8c044c6..751e9dbd50 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -813,16 +813,12 @@ void ozone_init_horizontal_list(ozone_handle_t *ozone) for (i = 0; i < list_size; i++) { - const char *playlist_file = NULL; - char *console_name = NULL; char playlist_file_noext[255]; + char *console_name = NULL; + const char *playlist_file = ozone->horizontal_list.list[i].path; playlist_file_noext[0] = '\0'; - /* Get playlist file name */ - file_list_get_at_offset(&ozone->horizontal_list, i, - &playlist_file, NULL, NULL, NULL); - if (!playlist_file) { file_list_set_alt_at_offset(&ozone->horizontal_list, i, NULL); @@ -907,16 +903,10 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) continue; } - file_list_get_at_offset(&ozone->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path) + if (!(path = ozone->horizontal_list.list[i].path)) continue; - - if (!string_ends_with_size(path, ".lpl", + if (string_ends_with_size(path, ".lpl", strlen(path), STRLEN_CONST(".lpl"))) - continue; - { struct texture_image ti; char sysname[PATH_MAX_LENGTH]; @@ -984,8 +974,6 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) } /* Console name */ - file_list_get_at_offset( - &ozone->horizontal_list, i, NULL, NULL, NULL, NULL); console_name = ozone->horizontal_list.list[i].alt ? ozone->horizontal_list.list[i].alt : ozone->horizontal_list.list[i].path; @@ -1017,15 +1005,14 @@ void ozone_context_destroy_horizontal_list(ozone_handle_t *ozone) if (!node) continue; - file_list_get_at_offset(&ozone->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path || !string_ends_with_size(path, ".lpl", - strlen(path), STRLEN_CONST(".lpl"))) + if (!(path = ozone->horizontal_list.list[i].path)) continue; - - video_driver_texture_unload(&node->icon); - video_driver_texture_unload(&node->content_icon); + if (string_ends_with_size(path, ".lpl", + strlen(path), STRLEN_CONST(".lpl"))) + { + video_driver_texture_unload(&node->icon); + video_driver_texture_unload(&node->content_icon); + } } } diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 46013f37ca..df16c7d2b9 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -1512,12 +1512,8 @@ static void stripes_set_title(stripes_handle_t *stripes) } else { - const char *path = NULL; - file_list_get_at_offset( - &stripes->horizontal_list, - stripes->categories_selection_ptr - (stripes->system_tab_end + 1), - &path, NULL, NULL, NULL); - + const char *path = stripes->horizontal_list.list[ + stripes->categories_selection_ptr - (stripes->system_tab_end + 1)].path; if (!path) return; @@ -1747,15 +1743,15 @@ static void stripes_context_destroy_horizontal_list(stripes_handle_t *stripes) if (!node) continue; - file_list_get_at_offset(&stripes->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path || !string_ends_with_size(path, ".lpl", - strlen(path), STRLEN_CONST(".lpl"))) + if (!(path = stripes->horizontal_list.list[i].path)) continue; - video_driver_texture_unload(&node->icon); - video_driver_texture_unload(&node->content_icon); + if (string_ends_with_size(path, ".lpl", + strlen(path), STRLEN_CONST(".lpl"))) + { + video_driver_texture_unload(&node->icon); + video_driver_texture_unload(&node->content_icon); + } } } @@ -1836,23 +1832,17 @@ static void stripes_context_reset_horizontal_list( for (i = 0; i < list_size; i++) { const char *path = NULL; - stripes_node_t *node = + stripes_node_t *node = stripes_get_userdata_from_horizontal_list(stripes, i); if (!node) - { - node = stripes_node_allocate_userdata(stripes, i); - if (!node) + if (!(node = stripes_node_allocate_userdata(stripes, i))) continue; - } - file_list_get_at_offset(&stripes->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path || !string_ends_with_size(path, ".lpl", - strlen(path), STRLEN_CONST(".lpl"))) + if (!(path = stripes->horizontal_list.list[i].path)) continue; - + if (string_ends_with_size(path, ".lpl", + strlen(path), STRLEN_CONST(".lpl"))) { struct texture_image ti; char sysname[256]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 704bf1c89c..299cdc771c 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1879,11 +1879,8 @@ static void xmb_set_title(xmb_handle_t *xmb) menu_entries_get_title(xmb->title_name, sizeof(xmb->title_name)); else { - const char *path = NULL; - - file_list_get_at_offset(&xmb->horizontal_list, - xmb->categories_selection_ptr - (xmb->system_tab_end + 1), - &path, NULL, NULL, NULL); + const char *path = xmb->horizontal_list.list[ + xmb->categories_selection_ptr - (xmb->system_tab_end + 1)].path; if (!path) return; @@ -2093,16 +2090,14 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb) if (!node) continue; - - file_list_get_at_offset(&xmb->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path || !string_ends_with_size(path, ".lpl", - strlen(path), STRLEN_CONST(".lpl"))) + if (!(path = xmb->horizontal_list.list[i].path)) continue; - - video_driver_texture_unload(&node->icon); - video_driver_texture_unload(&node->content_icon); + if (string_ends_with_size(path, ".lpl", + strlen(path), STRLEN_CONST(".lpl"))) + { + video_driver_texture_unload(&node->icon); + video_driver_texture_unload(&node->content_icon); + } } } @@ -2185,16 +2180,10 @@ static void xmb_context_reset_horizontal_list( xmb_get_userdata_from_horizontal_list(xmb, i); if (!node) - { - node = xmb_node_allocate_userdata(xmb, i); - if (!node) + if (!(node = xmb_node_allocate_userdata(xmb, i))) continue; - } - file_list_get_at_offset(&xmb->horizontal_list, i, - &path, NULL, NULL, NULL); - - if (!path) + if (!(path = xmb->horizontal_list.list[i].path)) continue; if (string_ends_with_size(path, ".lpl", diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6dc1601f7a..ecb2a6202a 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3460,10 +3460,8 @@ static unsigned menu_displaylist_parse_cores( for (i = 0; i < list_size; i++) { - unsigned type = 0; - const char *path = NULL; - - file_list_get_at_offset(info->list, i, &path, NULL, &type, NULL); + const char *path = info->list->list[i].path; + unsigned type = info->list->list[i].type; if (type == FILE_TYPE_CORE) { diff --git a/retroarch.c b/retroarch.c index 6c315d97f9..72c3a74ce5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1939,17 +1939,20 @@ static int generic_menu_iterate( #ifdef HAVE_NETWORKING case MENU_ENUM_LABEL_CORE_UPDATER_ENTRY: { - core_updater_list_t *core_list = core_updater_list_get_cached(); + core_updater_list_t *core_list = + core_updater_list_get_cached(); const core_updater_list_entry_t *entry = NULL; - const char *path = NULL; - - /* Get core path */ - file_list_get_at_offset(selection_buf, selection, &path, NULL, NULL, NULL); + const char *path = + selection_buf->list[selection].path; /* Search for specified core */ - if (core_list && path && - core_updater_list_get_filename(core_list, path, &entry) && - !string_is_empty(entry->description)) + if ( + core_list + && path + && core_updater_list_get_filename(core_list, + path, &entry) + && !string_is_empty(entry->description) + ) strlcpy(menu->menu_state_msg, entry->description, sizeof(menu->menu_state_msg)); else @@ -1963,20 +1966,17 @@ static int generic_menu_iterate( #endif case MENU_ENUM_LABEL_CORE_MANAGER_ENTRY: { - const char *path = NULL; core_info_ctx_find_t core_info; - - /* Get core path */ - file_list_get_at_offset(selection_buf, selection, &path, NULL, NULL, NULL); - + const char *path = selection_buf->list[selection].path; /* Search for specified core */ - core_info.inf = NULL; - core_info.path = path; + core_info.inf = NULL; + core_info.path = path; - if (path && - core_info_find(&core_info) && - !string_is_empty(core_info.inf->description)) - strlcpy(menu->menu_state_msg, core_info.inf->description, + if ( path + && core_info_find(&core_info) + && !string_is_empty(core_info.inf->description)) + strlcpy(menu->menu_state_msg, + core_info.inf->description, sizeof(menu->menu_state_msg)); else strlcpy(menu->menu_state_msg, @@ -2019,10 +2019,9 @@ static int generic_menu_iterate( } else { - unsigned type = 0; enum msg_hash_enums enum_idx = MSG_UNKNOWN; size_t selection = menu_st->selection_ptr; - file_list_get_at_offset(selection_buf, selection, NULL, NULL, &type, NULL); + unsigned type = selection_buf->list[selection].type; switch (type) {