Skip to content

Commit 771fc52

Browse files
authored
Make large read-only arrays static
This can avoid unnecessary waste of performance at runtime to use static data instead of filling out an array on the stack every time. Some of the CBS functions are called for every menu item created so this improves performance of menu navigation, especially large menus like playlists.
1 parent 45c3f93 commit 771fc52

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

menu/cbs/menu_cbs_deferred_push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
669669
int (*cb)(menu_displaylist_info_t *info);
670670
} deferred_info_list_t;
671671

672-
const deferred_info_list_t info_list[] = {
672+
static const deferred_info_list_t info_list[] = {
673673
{MENU_ENUM_LABEL_DEFERRED_DUMP_DISC_LIST, deferred_push_dump_disk_list},
674674
#ifdef HAVE_LAKKA
675675
{MENU_ENUM_LABEL_DEFERRED_EJECT_DISC, deferred_push_eject_disc},

menu/cbs/menu_cbs_get_value.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ static int menu_cbs_init_bind_get_string_representation_compare_type(
21232123
char *s2, size_t len2);
21242124
} info_range_list_t;
21252125

2126-
info_range_list_t info_list[] = {
2126+
static const info_range_list_t info_list[] = {
21272127
#ifdef HAVE_AUDIOMIXER
21282128
{
21292129
MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN,

menu/cbs/menu_cbs_ok.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8998,7 +8998,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
89988998
size_t idx, size_t entry_idx);
89998999
} temp_ok_list_t;
90009000

9001-
temp_ok_list_t ok_list[] = {
9001+
static const temp_ok_list_t ok_list[] = {
90029002
{MENU_ENUM_LABEL_QUICK_MENU_START_RECORDING, action_ok_start_recording},
90039003
{MENU_ENUM_LABEL_QUICK_MENU_START_STREAMING, action_ok_start_streaming},
90049004
{MENU_ENUM_LABEL_QUICK_MENU_STOP_RECORDING, action_ok_stop_recording},
@@ -9380,7 +9380,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
93809380
size_t idx, size_t entry_idx);
93819381
} temp_ok_list_t;
93829382

9383-
temp_ok_list_t ok_list[] = {
9383+
static const temp_ok_list_t ok_list[] = {
93849384
{MENU_ENUM_LABEL_OPEN_ARCHIVE_DETECT_CORE, action_ok_open_archive_detect_core},
93859385
{MENU_ENUM_LABEL_OPEN_ARCHIVE, action_ok_open_archive},
93869386
{MENU_ENUM_LABEL_LOAD_ARCHIVE_DETECT_CORE, action_ok_load_archive_detect_core},

menu/cbs/menu_cbs_sublabel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
21992199
char *s, size_t len);
22002200
} info_range_list_t;
22012201

2202-
info_range_list_t info_list[] = {
2202+
static const info_range_list_t info_list[] = {
22032203
{
22042204
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN,
22052205
MENU_SETTINGS_INPUT_DESC_KBD_END,
@@ -5781,7 +5781,7 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
57815781
} info_single_list_t;
57825782

57835783
/* Entries with %u player index placeholder. */
5784-
info_single_list_t info_list[] = {
5784+
static const info_single_list_t info_list[] = {
57855785
#if 0
57865786
{
57875787
MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE,

menu/cbs/menu_cbs_title.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ static int action_get_title_group_settings(const char *path, const char *label,
907907
/* Note: MENU_ENUM_LABEL_HORIZONTAL_MENU *is* a playlist
908908
* tab, but its actual title is set elsewhere - so treat
909909
* it as a generic top-level item */
910-
title_info_list_t info_list[] = {
910+
static const title_info_list_t info_list[] = {
911911
{MENU_ENUM_LABEL_MAIN_MENU, MENU_ENUM_LABEL_VALUE_MAIN_MENU, false },
912912
{MENU_ENUM_LABEL_HISTORY_TAB, MENU_ENUM_LABEL_VALUE_HISTORY_TAB, true },
913913
{MENU_ENUM_LABEL_FAVORITES_TAB, MENU_ENUM_LABEL_VALUE_FAVORITES_TAB, true },
@@ -978,7 +978,7 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs,
978978
unsigned type, char *s, size_t len);
979979
} title_info_list_t;
980980

981-
title_info_list_t info_list[] = {
981+
static const title_info_list_t info_list[] = {
982982
{MENU_ENUM_LABEL_DEFERRED_REMAPPINGS_PORT_LIST, action_get_title_remap_port},
983983
{MENU_ENUM_LABEL_DEFERRED_CORE_SETTINGS_LIST, action_get_core_settings_list},
984984
{MENU_ENUM_LABEL_DEFERRED_CORE_INFORMATION_LIST, action_get_core_information_list},
@@ -1812,7 +1812,7 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs,
18121812
unsigned type, char *s, size_t len);
18131813
} title_info_list_t;
18141814

1815-
title_info_list_t info_list[] = {
1815+
static const title_info_list_t info_list[] = {
18161816
#ifdef HAVE_AUDIOMIXER
18171817
{MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST, action_get_title_mixer_stream_actions},
18181818
#endif

menu/menu_displaylist.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
22682268

22692269
/* Supports %s: yes/no */
22702270
{
2271-
struct menu_features_info
2271+
static const struct menu_features_info
22722272
{
22732273
bool enabled;
22742274
enum msg_hash_enums msg;
@@ -7391,7 +7391,7 @@ unsigned menu_displaylist_build_list(
73917391
break;
73927392
case DISPLAYLIST_INPUT_TURBO_FIRE_SETTINGS_LIST:
73937393
{
7394-
menu_displaylist_build_info_t build_list[] = {
7394+
static const menu_displaylist_build_info_t build_list[] = {
73957395
{MENU_ENUM_LABEL_INPUT_TURBO_ENABLE, PARSE_ONLY_BOOL},
73967396
{MENU_ENUM_LABEL_INPUT_TURBO_MODE, PARSE_ONLY_UINT},
73977397
{MENU_ENUM_LABEL_INPUT_TURBO_BIND, PARSE_ONLY_INT},
@@ -9195,7 +9195,7 @@ unsigned menu_displaylist_build_list(
91959195
#ifdef HAVE_CHEATS
91969196
{
91979197
char cheat_label[64];
9198-
menu_displaylist_build_info_t build_list[] = {
9198+
static const menu_displaylist_build_info_t build_list[] = {
91999199
{MENU_ENUM_LABEL_CHEAT_START_OR_RESTART, PARSE_ONLY_UINT },
92009200
{MENU_ENUM_LABEL_CHEAT_BIG_ENDIAN, PARSE_ONLY_BOOL },
92019201
{MENU_ENUM_LABEL_CHEAT_SEARCH_EXACT, PARSE_ONLY_UINT },
@@ -9298,7 +9298,7 @@ unsigned menu_displaylist_build_list(
92989298
}
92999299

93009300
{
9301-
menu_displaylist_build_info_t build_list[] = {
9301+
static const menu_displaylist_build_info_t build_list[] = {
93029302
{MENU_ENUM_LABEL_CHEAT_IDX, PARSE_ONLY_UINT },
93039303
{MENU_ENUM_LABEL_CHEAT_STATE, PARSE_ONLY_BOOL },
93049304
{MENU_ENUM_LABEL_CHEAT_DESC, PARSE_ONLY_STRING},
@@ -9323,7 +9323,7 @@ unsigned menu_displaylist_build_list(
93239323
}
93249324
else
93259325
{
9326-
menu_displaylist_build_info_t build_list[] = {
9326+
static const menu_displaylist_build_info_t build_list[] = {
93279327
{MENU_ENUM_LABEL_CHEAT_MEMORY_SEARCH_SIZE, PARSE_ONLY_UINT },
93289328
{MENU_ENUM_LABEL_CHEAT_TYPE, PARSE_ONLY_UINT },
93299329
{MENU_ENUM_LABEL_CHEAT_VALUE, PARSE_ONLY_UINT },
@@ -9428,7 +9428,7 @@ unsigned menu_displaylist_build_list(
94289428
break;
94299429
case DISPLAYLIST_ACCOUNTS_YOUTUBE_LIST:
94309430
{
9431-
menu_displaylist_build_info_t build_list[] = {
9431+
static const menu_displaylist_build_info_t build_list[] = {
94329432
{MENU_ENUM_LABEL_YOUTUBE_STREAM_KEY, PARSE_ONLY_STRING},
94339433
};
94349434

@@ -9693,7 +9693,7 @@ unsigned menu_displaylist_build_list(
96939693
break;
96949694
case DISPLAYLIST_MIDI_SETTINGS_LIST:
96959695
{
9696-
menu_displaylist_build_info_t build_list[] = {
9696+
static const menu_displaylist_build_info_t build_list[] = {
96979697
{MENU_ENUM_LABEL_MIDI_OUTPUT, PARSE_ONLY_STRING},
96989698
{MENU_ENUM_LABEL_MIDI_INPUT, PARSE_ONLY_STRING},
96999699
{MENU_ENUM_LABEL_MIDI_VOLUME, PARSE_ONLY_UINT },
@@ -10147,7 +10147,7 @@ unsigned menu_displaylist_build_list(
1014710147
break;
1014810148
case DISPLAYLIST_CRT_SWITCHRES_SETTINGS_LIST:
1014910149
{
10150-
menu_displaylist_build_info_t build_list[] = {
10150+
static const menu_displaylist_build_info_t build_list[] = {
1015110151
{MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, PARSE_ONLY_UINT},
1015210152
{MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, PARSE_ONLY_UINT},
1015310153
{MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING, PARSE_ONLY_INT },
@@ -10169,7 +10169,7 @@ unsigned menu_displaylist_build_list(
1016910169
#ifdef HAVE_LAKKA
1017010170
case DISPLAYLIST_LAKKA_SERVICES_LIST:
1017110171
{
10172-
menu_displaylist_build_info_t build_list[] = {
10172+
static const menu_displaylist_build_info_t build_list[] = {
1017310173
{MENU_ENUM_LABEL_SSH_ENABLE, PARSE_ONLY_BOOL},
1017410174
{MENU_ENUM_LABEL_SAMBA_ENABLE, PARSE_ONLY_BOOL},
1017510175
{MENU_ENUM_LABEL_BLUETOOTH_ENABLE, PARSE_ONLY_BOOL},
@@ -10190,7 +10190,7 @@ unsigned menu_displaylist_build_list(
1019010190
#ifdef HAVE_LAKKA_SWITCH
1019110191
case DISPLAYLIST_LAKKA_SWITCH_OPTIONS_LIST:
1019210192
{
10193-
menu_displaylist_build_info_t build_list[] = {
10193+
static const menu_displaylist_build_info_t build_list[] = {
1019410194
{MENU_ENUM_LABEL_SWITCH_OC_ENABLE, PARSE_ONLY_BOOL},
1019510195
{MENU_ENUM_LABEL_SWITCH_CEC_ENABLE, PARSE_ONLY_BOOL},
1019610196
{MENU_ENUM_LABEL_BLUETOOTH_ERTM_DISABLE, PARSE_ONLY_BOOL},
@@ -10276,7 +10276,7 @@ unsigned menu_displaylist_build_list(
1027610276
break;
1027710277
case DISPLAYLIST_MENU_FILE_BROWSER_SETTINGS_LIST:
1027810278
{
10279-
menu_displaylist_build_info_t build_list[] = {
10279+
static const menu_displaylist_build_info_t build_list[] = {
1028010280
{MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY, PARSE_ONLY_DIR},
1028110281
{MENU_ENUM_LABEL_CACHE_DIRECTORY, PARSE_ONLY_DIR},
1028210282
{MENU_ENUM_LABEL_SHOW_HIDDEN_FILES, PARSE_ONLY_BOOL},
@@ -10299,7 +10299,7 @@ unsigned menu_displaylist_build_list(
1029910299
break;
1030010300
case DISPLAYLIST_ACCOUNTS_LIST:
1030110301
{
10302-
menu_displaylist_build_info_t build_list[] = {
10302+
static const menu_displaylist_build_info_t build_list[] = {
1030310303
{MENU_ENUM_LABEL_ACCOUNTS_RETRO_ACHIEVEMENTS, PARSE_ACTION},
1030410304
{MENU_ENUM_LABEL_ACCOUNTS_YOUTUBE, PARSE_ACTION},
1030510305
{MENU_ENUM_LABEL_ACCOUNTS_TWITCH, PARSE_ACTION},
@@ -10317,7 +10317,7 @@ unsigned menu_displaylist_build_list(
1031710317
break;
1031810318
case DISPLAYLIST_ACCOUNTS_CHEEVOS_LIST:
1031910319
{
10320-
menu_displaylist_build_info_t build_list[] = {
10320+
static const menu_displaylist_build_info_t build_list[] = {
1032110321
{MENU_ENUM_LABEL_CHEEVOS_USERNAME, PARSE_ONLY_STRING},
1032210322
{MENU_ENUM_LABEL_CHEEVOS_PASSWORD, PARSE_ONLY_STRING},
1032310323
};
@@ -10916,7 +10916,7 @@ unsigned menu_displaylist_build_list(
1091610916
}
1091710917
case DISPLAYLIST_PRIVACY_SETTINGS_LIST:
1091810918
{
10919-
menu_displaylist_build_info_t build_list[] = {
10919+
static const menu_displaylist_build_info_t build_list[] = {
1092010920
{MENU_ENUM_LABEL_CAMERA_ALLOW, PARSE_ONLY_BOOL},
1092110921
{MENU_ENUM_LABEL_DISCORD_ALLOW, PARSE_ONLY_BOOL},
1092210922
{MENU_ENUM_LABEL_LOCATION_ALLOW, PARSE_ONLY_BOOL},
@@ -11192,7 +11192,7 @@ unsigned menu_displaylist_build_list(
1119211192
break;
1119311193
case DISPLAYLIST_POWER_MANAGEMENT_SETTINGS_LIST:
1119411194
{
11195-
menu_displaylist_build_info_t build_list[] = {
11195+
static const menu_displaylist_build_info_t build_list[] = {
1119611196
{MENU_ENUM_LABEL_FASTFORWARD_FRAMESKIP, PARSE_ONLY_BOOL},
1119711197
{MENU_ENUM_LABEL_SUSTAINED_PERFORMANCE_MODE, PARSE_ONLY_BOOL},
1119811198
{MENU_ENUM_LABEL_CPU_PERFPOWER, PARSE_ACTION},
@@ -11226,7 +11226,7 @@ unsigned menu_displaylist_build_list(
1122611226
case DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST:
1122711227
{
1122811228
/* Not used */
11229-
menu_displaylist_build_info_t build_list[] = {
11229+
static const menu_displaylist_build_info_t build_list[] = {
1123011230
{MENU_ENUM_LABEL_ONSCREEN_NOTIFICATIONS_SETTINGS, PARSE_ACTION},
1123111231
#if defined(HAVE_OVERLAY)
1123211232
{MENU_ENUM_LABEL_ONSCREEN_OVERLAY_SETTINGS, PARSE_ACTION},
@@ -11244,7 +11244,7 @@ unsigned menu_displaylist_build_list(
1124411244
break;
1124511245
case DISPLAYLIST_USER_SETTINGS_LIST:
1124611246
{
11247-
menu_displaylist_build_info_t build_list[] = {
11247+
static const menu_displaylist_build_info_t build_list[] = {
1124811248
{MENU_ENUM_LABEL_PRIVACY_SETTINGS, PARSE_ACTION},
1124911249
{MENU_ENUM_LABEL_ACCOUNTS_LIST, PARSE_ACTION},
1125011250
{MENU_ENUM_LABEL_NETPLAY_NICKNAME, PARSE_ONLY_STRING},
@@ -11261,7 +11261,7 @@ unsigned menu_displaylist_build_list(
1126111261
break;
1126211262
case DISPLAYLIST_UPDATER_SETTINGS_LIST:
1126311263
{
11264-
menu_displaylist_build_info_t build_list[] = {
11264+
static const menu_displaylist_build_info_t build_list[] = {
1126511265
{MENU_ENUM_LABEL_CORE_UPDATER_BUILDBOT_URL, PARSE_ONLY_STRING},
1126611266
{MENU_ENUM_LABEL_BUILDBOT_ASSETS_URL, PARSE_ONLY_STRING},
1126711267
{MENU_ENUM_LABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, PARSE_ONLY_BOOL},
@@ -11281,7 +11281,7 @@ unsigned menu_displaylist_build_list(
1128111281
break;
1128211282
case DISPLAYLIST_MENU_SOUNDS_LIST:
1128311283
{
11284-
menu_displaylist_build_info_t build_list[] = {
11284+
static const menu_displaylist_build_info_t build_list[] = {
1128511285
{MENU_ENUM_LABEL_AUDIO_ENABLE_MENU, PARSE_ONLY_BOOL},
1128611286
{MENU_ENUM_LABEL_MENU_SOUND_OK, PARSE_ONLY_BOOL},
1128711287
{MENU_ENUM_LABEL_MENU_SOUND_CANCEL, PARSE_ONLY_BOOL},
@@ -11301,7 +11301,7 @@ unsigned menu_displaylist_build_list(
1130111301
break;
1130211302
case DISPLAYLIST_SETTINGS_VIEWS_SETTINGS_LIST:
1130311303
{
11304-
menu_displaylist_build_info_t build_list[] = {
11304+
static const menu_displaylist_build_info_t build_list[] = {
1130511305
{MENU_ENUM_LABEL_SETTINGS_SHOW_USER_INTERFACE, PARSE_ONLY_BOOL},
1130611306
{MENU_ENUM_LABEL_SETTINGS_SHOW_ONSCREEN_DISPLAY, PARSE_ONLY_BOOL},
1130711307
{MENU_ENUM_LABEL_SETTINGS_SHOW_FILE_BROWSER, PARSE_ONLY_BOOL},
@@ -11346,7 +11346,7 @@ unsigned menu_displaylist_build_list(
1134611346
break;
1134711347
case DISPLAYLIST_QUICK_MENU_VIEWS_SETTINGS_LIST:
1134811348
{
11349-
menu_displaylist_build_info_t build_list[] = {
11349+
static const menu_displaylist_build_info_t build_list[] = {
1135011350
{MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESUME_CONTENT, PARSE_ONLY_BOOL},
1135111351
{MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESTART_CONTENT, PARSE_ONLY_BOOL},
1135211352
{MENU_ENUM_LABEL_QUICK_MENU_SHOW_CLOSE_CONTENT, PARSE_ONLY_BOOL},
@@ -11409,7 +11409,7 @@ unsigned menu_displaylist_build_list(
1140911409
#endif
1141011410

1141111411
{
11412-
menu_displaylist_build_info_t build_list[] = {
11412+
static const menu_displaylist_build_info_t build_list[] = {
1141311413
{MENU_ENUM_LABEL_QUICK_MENU_SHOW_SET_CORE_ASSOCIATION, PARSE_ONLY_BOOL},
1141411414
{MENU_ENUM_LABEL_QUICK_MENU_SHOW_RESET_CORE_ASSOCIATION, PARSE_ONLY_BOOL},
1141511415
#ifdef HAVE_NETWORKING
@@ -11430,7 +11430,7 @@ unsigned menu_displaylist_build_list(
1143011430
break;
1143111431
case DISPLAYLIST_CORE_SETTINGS_LIST:
1143211432
{
11433-
menu_displaylist_build_info_t build_list[] = {
11433+
static const menu_displaylist_build_info_t build_list[] = {
1143411434
{MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE, PARSE_ONLY_BOOL},
1143511435
{MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS, PARSE_ONLY_BOOL},
1143611436
{MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE, PARSE_ONLY_BOOL},
@@ -11472,7 +11472,7 @@ unsigned menu_displaylist_build_list(
1147211472
break;
1147311473
case DISPLAYLIST_CONFIGURATION_SETTINGS_LIST:
1147411474
{
11475-
menu_displaylist_build_info_t build_list[] = {
11475+
static const menu_displaylist_build_info_t build_list[] = {
1147611476
{MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT, PARSE_ONLY_BOOL},
1147711477
{MENU_ENUM_LABEL_REMAP_SAVE_ON_EXIT, PARSE_ONLY_BOOL},
1147811478
{MENU_ENUM_LABEL_GAME_SPECIFIC_OPTIONS, PARSE_ONLY_BOOL},
@@ -11493,7 +11493,7 @@ unsigned menu_displaylist_build_list(
1149311493
break;
1149411494
case DISPLAYLIST_DIRECTORY_SETTINGS_LIST:
1149511495
{
11496-
menu_displaylist_build_info_t build_list[] = {
11496+
static const menu_displaylist_build_info_t build_list[] = {
1149711497
{MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY, PARSE_ONLY_DIR},
1149811498
{MENU_ENUM_LABEL_CACHE_DIRECTORY, PARSE_ONLY_DIR},
1149911499
{MENU_ENUM_LABEL_SYSTEM_DIRECTORY, PARSE_ONLY_DIR},
@@ -11547,7 +11547,7 @@ unsigned menu_displaylist_build_list(
1154711547
break;
1154811548
case DISPLAYLIST_DRIVER_SETTINGS_LIST:
1154911549
{
11550-
menu_displaylist_build_info_t build_list[] = {
11550+
static const menu_displaylist_build_info_t build_list[] = {
1155111551
{MENU_ENUM_LABEL_MENU_DRIVER, PARSE_ONLY_STRING_OPTIONS},
1155211552
{MENU_ENUM_LABEL_VIDEO_DRIVER, PARSE_ONLY_STRING_OPTIONS},
1155311553
{MENU_ENUM_LABEL_AUDIO_DRIVER, PARSE_ONLY_STRING_OPTIONS},

0 commit comments

Comments
 (0)