Further optimizations to menu_entry_get - get rid of some unnecessary

small wrapper functions
This commit is contained in:
twinaphex 2020-06-07 20:02:12 +02:00
parent 45896eb26e
commit 058adf247c
8 changed files with 38 additions and 47 deletions

View File

@ -3471,10 +3471,11 @@ static void materialui_render_menu_entry_default(
menu_entry_get_rich_label(entry, &entry_label);
menu_entry_get_value(entry, &entry_value);
menu_entry_get_sublabel(entry, &entry_sublabel);
entry_type = menu_entry_get_type_new(entry);
entry_type = entry->type;
entry_file_type = msg_hash_to_file_type(msg_hash_calculate(entry_value));
entry_value_type = materialui_get_entry_value_type(
entry_file_type = msg_hash_to_file_type(
msg_hash_calculate(entry_value));
entry_value_type = materialui_get_entry_value_type(
mui, entry_value, entry->checked, entry_type, entry_file_type);
/* Draw entry icon
@ -8657,9 +8658,10 @@ static int materialui_pointer_up_swipe_horz_default(
/* Parse entry */
menu_entry_get_value(&last_entry, &entry_value);
entry_type = menu_entry_get_type_new(&last_entry);
entry_file_type = msg_hash_to_file_type(msg_hash_calculate(entry_value));
entry_value_type = materialui_get_entry_value_type(
entry_type = last_entry.type;
entry_file_type = msg_hash_to_file_type(
msg_hash_calculate(entry_value));
entry_value_type = materialui_get_entry_value_type(
mui, entry_value, last_entry.checked, entry_type, entry_file_type);
/* If entry has a 'settings' type, reset scroll position */

View File

@ -2266,7 +2266,7 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation)
entry.sublabel_enabled = false;
menu_entry_get(&entry, 0, selection, NULL, true);
entry_type = menu_entry_get_type_new(&entry);
entry_type = entry.type;
ozone->selection_old = ozone->selection;
ozone->selection = new_selection;

View File

@ -258,9 +258,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone)
ozone->empty_playlist = tex == ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO];
}
else
{
ozone->empty_playlist = false;
}
/* Cache node */
node = (ozone_node_t*)file_list_get_userdata_at_offset(selection_buf, i);

View File

@ -3718,14 +3718,13 @@ static void rgui_render(void *data,
{
/* Resize fields according to actual length of value string */
entry_value_len = (unsigned)strlen(entry_value);
entry_value_len = entry_value_len > rgui_term_layout.value_maxlen ?
rgui_term_layout.value_maxlen : entry_value_len;
}
else
{
/* Use classic fixed width layout */
entry_value_len = menu_entry_get_spacing(&entry);
entry_value_len = (entry_value_len
> rgui_term_layout.value_maxlen)
? rgui_term_layout.value_maxlen
: entry_value_len;
}
else /* Use classic fixed width layout */
entry_value_len = entry.spacing;
/* Update width of entry title field */
entry_title_max_len -= entry_value_len + 2;

View File

@ -903,7 +903,7 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos)
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, NULL, true);
entry_type = menu_entry_get_type_new(&entry);
entry_type = entry.type;
if (entry_type == FILE_TYPE_IMAGEVIEWER || entry_type == FILE_TYPE_IMAGE)
{
@ -2401,7 +2401,7 @@ static int stripes_draw_item(
if (icon_x < -half_size || icon_x > width)
goto iterate;
entry_type = menu_entry_get_type_new(entry);
entry_type = entry.type;
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
{

View File

@ -1394,7 +1394,7 @@ static void xmb_selection_pointer_changed(
entry.value_enabled = false;
entry.sublabel_enabled = false;
menu_entry_get(&entry, 0, selection, NULL, true);
entry_type = menu_entry_get_type_new(&entry);
entry_type = entry.type;
if ( (entry_type == FILE_TYPE_IMAGEVIEWER) ||
(entry_type == FILE_TYPE_IMAGE))
@ -3044,7 +3044,7 @@ static int xmb_draw_item(
entry.label_enabled = false;
entry.sublabel_enabled = (i == current);
menu_entry_get(&entry, 0, i, list, true);
entry_type = menu_entry_get_type_new(&entry);
entry_type = entry.type;
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
{

View File

@ -206,10 +206,6 @@ void menu_entry_get_path(menu_entry_t *entry, const char **path);
void menu_entry_get_label(menu_entry_t *entry, const char **label);
unsigned menu_entry_get_spacing(menu_entry_t *entry);
unsigned menu_entry_get_type_new(menu_entry_t *entry);
uint32_t menu_entry_get_bool_value(uint32_t i);
struct string_list *menu_entry_enum_values(uint32_t i);

View File

@ -3052,8 +3052,16 @@ static void get_current_menu_value(struct rarch_state *p_rarch,
struct menu_state *menu_st = &p_rarch->menu_driver_state;
menu_entry_init(&entry);
entry.path_enabled = false;
entry.label_enabled = false;
entry.rich_label_enabled = false;
entry.sublabel_enabled = false;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
menu_entry_get_value(&entry, &entry_label);
if (entry.enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
entry_label = entry.password_value;
else
entry_label = entry.value;
strlcpy(retstr, entry_label, max);
}
@ -3080,10 +3088,12 @@ static void get_current_menu_sublabel(struct rarch_state *p_rarch,
struct menu_state *menu_st = &p_rarch->menu_driver_state;
menu_entry_init(&entry);
entry.path_enabled = false;
entry.label_enabled = false;
entry.rich_label_enabled = false;
entry.value_enabled = false;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
menu_entry_get_sublabel(&entry, &entry_sublabel);
strlcpy(retstr, entry_sublabel, max);
strlcpy(retstr, entry.sublabel, max);
}
#endif
@ -3336,14 +3346,14 @@ static int generic_menu_iterate(
selection = MAX(MIN(selection, (menu_entries_get_size() - 1)), 0);
menu_entry_init(&entry);
/* Note: If menu_entry_action() is modified,
/* NOTE: If menu_entry_action() is modified,
* will have to verify that these parameters
* remain unused... */
entry.rich_label_enabled = false;
entry.value_enabled = false;
entry.sublabel_enabled = false;
menu_entry_get(&entry, 0, selection, NULL, false);
ret = menu_entry_action(&entry,
ret = menu_entry_action(&entry,
selection, (enum menu_action)action);
if (ret)
goto end;
@ -3773,20 +3783,6 @@ void menu_entry_get_label(menu_entry_t *entry, const char **label)
*label = entry->label;
}
unsigned menu_entry_get_spacing(menu_entry_t *entry)
{
if (entry)
return entry->spacing;
return 0;
}
unsigned menu_entry_get_type_new(menu_entry_t *entry)
{
if (!entry)
return 0;
return entry->type;
}
uint32_t menu_entry_get_bool_value(uint32_t i)
{
struct rarch_state *p_rarch = &rarch_st;
@ -3950,7 +3946,7 @@ void menu_entry_get_value(menu_entry_t *entry, const char **value)
if (!entry || !value)
return;
if (menu_entry_is_password(entry))
if (entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
*value = entry->password_value;
else
*value = entry->value;
@ -4074,7 +4070,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
if (!string_is_empty(entry->value))
{
if (menu_entry_is_password(entry))
if (entry->enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
{
size_t size, i;
size = strlcpy(entry->password_value, entry->value,
@ -23923,7 +23919,7 @@ static void menu_input_post_iterate(
entry.sublabel_enabled = false;
menu_entry_get(&entry, 0, selection, NULL, false);
*ret = menu_input_pointer_post_iterate(p_rarch,
*ret = menu_input_pointer_post_iterate(p_rarch,
current_time, cbs, &entry, action);
}
}