mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
(menu_cbs_get_value.c) Cut down on all the slow menu_setting_find
calls
This commit is contained in:
parent
879cb375e7
commit
f6dc06ac10
@ -68,9 +68,9 @@ static void menu_action_setting_audio_mixer_stream_name(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN);
|
||||
unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN);
|
||||
*w = 19;
|
||||
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
|
||||
if (offset >= AUDIO_MIXER_MAX_SYSTEM_STREAMS)
|
||||
@ -371,8 +371,10 @@ static void menu_action_setting_disp_set_label_shader_parameter(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_disp_set_label_shader_parameter_internal(list, w, type, i,
|
||||
label, s, len, path, s2, len2, MENU_SETTINGS_SHADER_PARAMETER_0);
|
||||
menu_action_setting_disp_set_label_shader_parameter_internal(
|
||||
list, w, type, i,
|
||||
label, s, len, path, s2, len2,
|
||||
MENU_SETTINGS_SHADER_PARAMETER_0);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_shader_preset_parameter(
|
||||
@ -383,8 +385,10 @@ static void menu_action_setting_disp_set_label_shader_preset_parameter(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_disp_set_label_shader_parameter_internal(list, w, type, i,
|
||||
label, s, len, path, s2, len2, MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
|
||||
menu_action_setting_disp_set_label_shader_parameter_internal(
|
||||
list, w, type, i,
|
||||
label, s, len, path, s2, len2,
|
||||
MENU_SETTINGS_SHADER_PRESET_PARAMETER_0);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_shader_scale_pass(
|
||||
@ -395,7 +399,6 @@ static void menu_action_setting_disp_set_label_shader_scale_pass(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
unsigned pass = 0;
|
||||
unsigned scale_value = 0;
|
||||
struct video_shader *shader = menu_shader_get();
|
||||
struct video_shader_pass *shader_pass = shader ? &shader->pass[type - MENU_SETTINGS_SHADER_PASS_SCALE_0] : NULL;
|
||||
@ -404,9 +407,6 @@ static void menu_action_setting_disp_set_label_shader_scale_pass(
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
|
||||
(void)pass;
|
||||
(void)scale_value;
|
||||
|
||||
if (!shader_pass)
|
||||
return;
|
||||
|
||||
@ -571,41 +571,33 @@ static void menu_action_setting_disp_set_label_input_desc(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
rarch_system_info_t *system = runloop_get_system_info();
|
||||
unsigned remap_idx;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char* descriptor = NULL;
|
||||
char buf[256];
|
||||
|
||||
unsigned btn_idx, user_idx, remap_idx;
|
||||
unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
|
||||
unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx;
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
|
||||
btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx;
|
||||
remap_idx =
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx];
|
||||
|
||||
if (!system)
|
||||
return;
|
||||
|
||||
if (remap_idx != RARCH_UNMAPPED)
|
||||
descriptor = system->input_desc_btn[user_idx][remap_idx];
|
||||
descriptor =
|
||||
runloop_get_system_info()->input_desc_btn[user_idx][remap_idx];
|
||||
|
||||
if (!string_is_empty(descriptor) && remap_idx < RARCH_FIRST_CUSTOM_BIND)
|
||||
strlcpy(s, descriptor, len);
|
||||
else if (!string_is_empty(descriptor) && remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 == 0)
|
||||
strlcpy(s, "---", len);
|
||||
|
||||
if (!string_is_empty(descriptor))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s %c", descriptor, '+');
|
||||
strlcpy(s, buf, len);
|
||||
if (remap_idx < RARCH_FIRST_CUSTOM_BIND)
|
||||
strlcpy(s, descriptor, len);
|
||||
else if (!string_is_empty(descriptor) && remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 == 0)
|
||||
snprintf(s, len, "%s %c", descriptor, '+');
|
||||
else if (remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 != 0)
|
||||
snprintf(s, len, "%s %c", descriptor, '-');
|
||||
}
|
||||
else if (!string_is_empty(descriptor) && remap_idx >= RARCH_FIRST_CUSTOM_BIND && remap_idx % 2 != 0)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s %c", descriptor, '-');
|
||||
strlcpy(s, buf, len);
|
||||
}
|
||||
else
|
||||
strlcpy(s, "---", len);
|
||||
|
||||
*w = 19;
|
||||
strlcpy(s2, path, len2);
|
||||
@ -693,10 +685,10 @@ static void menu_action_setting_disp_set_label_cheat_match(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
unsigned int address = 0;
|
||||
unsigned int address = 0;
|
||||
unsigned int address_mask = 0;
|
||||
unsigned int prev_val = 0;
|
||||
unsigned int curr_val = 0 ;
|
||||
unsigned int prev_val = 0;
|
||||
unsigned int curr_val = 0;
|
||||
cheat_manager_match_action(CHEAT_MATCH_ACTION_TYPE_VIEW, cheat_manager_state.match_idx, &address, &address_mask, &prev_val, &curr_val);
|
||||
|
||||
snprintf(s, len, "Prev: %u Curr: %u", prev_val, curr_val);
|
||||
@ -916,19 +908,12 @@ static void menu_action_setting_disp_set_label_menu_video_resolution(
|
||||
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
|
||||
}
|
||||
|
||||
static void menu_action_setting_generic_disp_set_label(
|
||||
unsigned *w, char *s, size_t len,
|
||||
const char *path, const char *label,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
*s = '\0';
|
||||
|
||||
if (label)
|
||||
strlcpy(s, label, len);
|
||||
*w = (unsigned)strlen(s);
|
||||
|
||||
strlcpy(s2, path, len2);
|
||||
}
|
||||
#define MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len, path, label, s2, len2) \
|
||||
*s = '\0'; \
|
||||
if (label) \
|
||||
strlcpy(s, label, len); \
|
||||
*w = (unsigned)strlen(s); \
|
||||
strlcpy(s2, path, len2)
|
||||
|
||||
static void menu_action_setting_disp_set_label_menu_file_plain(
|
||||
file_list_t* list,
|
||||
@ -938,7 +923,7 @@ static void menu_action_setting_disp_set_label_menu_file_plain(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(FILE)", s2, len2);
|
||||
}
|
||||
|
||||
@ -950,7 +935,7 @@ static void menu_action_setting_disp_set_label_menu_file_imageviewer(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(IMAGE)", s2, len2);
|
||||
}
|
||||
|
||||
@ -962,7 +947,7 @@ static void menu_action_setting_disp_set_label_movie(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(MOVIE)", s2, len2);
|
||||
}
|
||||
|
||||
@ -974,22 +959,10 @@ static void menu_action_setting_disp_set_label_music(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(MUSIC)", s2, len2);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_menu_file_use_directory(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
path, NULL, s2, len2);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_menu_file_directory(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
@ -998,11 +971,11 @@ static void menu_action_setting_disp_set_label_menu_file_directory(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(DIR)", s2, len2);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_menu_file_parent_directory(
|
||||
static void menu_action_setting_disp_set_label_generic(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
@ -1010,7 +983,7 @@ static void menu_action_setting_disp_set_label_menu_file_parent_directory(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, NULL, s2, len2);
|
||||
}
|
||||
|
||||
@ -1022,7 +995,7 @@ static void menu_action_setting_disp_set_label_menu_file_carchive(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(COMP)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1034,7 +1007,7 @@ static void menu_action_setting_disp_set_label_menu_file_shader(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(SHADER)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1046,7 +1019,7 @@ static void menu_action_setting_disp_set_label_menu_file_shader_preset(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(PRESET)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1058,7 +1031,7 @@ static void menu_action_setting_disp_set_label_menu_file_in_carchive(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(CFILE)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1070,7 +1043,7 @@ static void menu_action_setting_disp_set_label_menu_file_overlay(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(OVERLAY)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1083,8 +1056,8 @@ static void menu_action_setting_disp_set_label_menu_file_video_layout(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
path, "(Video Layout)", s2, len2);
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(LAYOUT)", s2, len2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1096,7 +1069,7 @@ static void menu_action_setting_disp_set_label_menu_file_config(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(CONFIG)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1108,7 +1081,7 @@ static void menu_action_setting_disp_set_label_menu_file_font(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(FONT)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1120,7 +1093,7 @@ static void menu_action_setting_disp_set_label_menu_file_filter(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(FILTER)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1132,7 +1105,7 @@ static void menu_action_setting_disp_set_label_menu_file_rdb(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(RDB)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1144,7 +1117,7 @@ static void menu_action_setting_disp_set_label_menu_file_cursor(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(CURSOR)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1156,7 +1129,7 @@ static void menu_action_setting_disp_set_label_menu_file_cheat(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
menu_action_setting_generic_disp_set_label(w, s, len,
|
||||
MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL(w, s, len,
|
||||
path, "(CHEAT)", s2, len2);
|
||||
}
|
||||
|
||||
@ -1357,7 +1330,8 @@ static void menu_action_setting_disp_set_label_playlist_sort_mode(
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_core_options(file_list_t* list,
|
||||
static void menu_action_setting_disp_set_label_core_options(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
@ -1379,9 +1353,11 @@ static void menu_action_setting_disp_set_label_core_options(file_list_t* list,
|
||||
|
||||
if (core_opt)
|
||||
{
|
||||
if (string_is_equal(core_opt, msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)))
|
||||
if (string_is_equal(core_opt,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)))
|
||||
core_opt = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON);
|
||||
else if (string_is_equal(core_opt, msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)))
|
||||
else if (string_is_equal(core_opt,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)))
|
||||
core_opt = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
|
||||
strlcpy(s, core_opt, len);
|
||||
}
|
||||
@ -1407,7 +1383,8 @@ static void menu_action_setting_disp_set_label_achievement_information(
|
||||
strlcpy(s2, path, len2);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_manual_content_scan_dir(file_list_t* list,
|
||||
static void menu_action_setting_disp_set_label_manual_content_scan_dir(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
@ -1427,7 +1404,8 @@ static void menu_action_setting_disp_set_label_manual_content_scan_dir(file_list
|
||||
strlcpy(s, content_dir, len);
|
||||
}
|
||||
|
||||
static void menu_action_setting_disp_set_label_manual_content_scan_system_name(file_list_t* list,
|
||||
static void menu_action_setting_disp_set_label_manual_content_scan_system_name(
|
||||
file_list_t* list,
|
||||
unsigned *w, unsigned type, unsigned i,
|
||||
const char *label,
|
||||
char *s, size_t len,
|
||||
@ -1504,7 +1482,8 @@ static void menu_action_setting_disp_set_label_setting_bool(file_list_t* list,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
rarch_setting_t *setting = menu_setting_find(list->list[i].label);
|
||||
menu_file_list_cbs_t *cbs = list->list[i].actiondata;
|
||||
rarch_setting_t *setting = cbs->setting;
|
||||
|
||||
*s = '\0';
|
||||
*w = 19;
|
||||
@ -1527,7 +1506,8 @@ static void menu_action_setting_disp_set_label_setting_string(file_list_t* list,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
rarch_setting_t *setting = menu_setting_find(list->list[i].label);
|
||||
menu_file_list_cbs_t *cbs = list->list[i].actiondata;
|
||||
rarch_setting_t *setting = cbs->setting;
|
||||
|
||||
*w = 19;
|
||||
|
||||
@ -1544,7 +1524,8 @@ static void menu_action_setting_disp_set_label_setting_path(file_list_t* list,
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
rarch_setting_t *setting = menu_setting_find(list->list[i].label);
|
||||
menu_file_list_cbs_t *cbs = list->list[i].actiondata;
|
||||
rarch_setting_t *setting = cbs->setting;
|
||||
const char *basename = setting ? path_basename(setting->value.target.string) : NULL;
|
||||
|
||||
*w = 19;
|
||||
@ -1716,9 +1697,7 @@ static int menu_cbs_init_bind_get_string_representation_compare_label(
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1815,17 +1794,14 @@ static int menu_cbs_init_bind_get_string_representation_compare_type(
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_menu_file_imageviewer);
|
||||
break;
|
||||
case FILE_TYPE_USE_DIRECTORY:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_menu_file_use_directory);
|
||||
break;
|
||||
case FILE_TYPE_DIRECTORY:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_menu_file_directory);
|
||||
break;
|
||||
case FILE_TYPE_PARENT_DIRECTORY:
|
||||
case FILE_TYPE_USE_DIRECTORY:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
menu_action_setting_disp_set_label_menu_file_parent_directory);
|
||||
menu_action_setting_disp_set_label_generic);
|
||||
break;
|
||||
case FILE_TYPE_CARCHIVE:
|
||||
BIND_ACTION_GET_VALUE(cbs,
|
||||
|
Loading…
x
Reference in New Issue
Block a user