mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-26 03:24:36 +00:00
(menu entries) Add sublabel_cache - this should prevent
unnecessary function calls if the contents of a sublabel don't change over time
This commit is contained in:
parent
5de666294e
commit
68d7411edf
@ -55,7 +55,7 @@
|
||||
static int (func_name)(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len) \
|
||||
{ \
|
||||
strlcpy(s, msg_hash_to_str(lbl), len); \
|
||||
return 0; \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
default_sublabel_macro(menu_action_sublabel_setting_audio_mixer_add_to_mixer_and_play,
|
||||
@ -708,7 +708,7 @@ static int action_bind_sublabel_audio_mixer_stream(
|
||||
audio_mixer_stream_t *stream = audio_driver_mixer_get_stream(offset);
|
||||
|
||||
if (!stream)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
switch (stream->state)
|
||||
{
|
||||
@ -796,7 +796,7 @@ static int action_bind_sublabel_netplay_room(
|
||||
unsigned offset = i - 3;
|
||||
|
||||
if (i < 1 || offset > (unsigned)netplay_room_count)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
ra_version = netplay_room_list[offset].retroarch_version;
|
||||
corename = netplay_room_list[offset].corename;
|
||||
|
@ -433,14 +433,26 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
|
||||
char tmp[512];
|
||||
tmp[0] = '\0';
|
||||
|
||||
cbs->action_sublabel(list,
|
||||
entry->type, (unsigned)i,
|
||||
label, path,
|
||||
tmp,
|
||||
sizeof(tmp));
|
||||
if (!string_is_empty(cbs->action_sublabel_cache))
|
||||
entry->sublabel = strdup(cbs->action_sublabel_cache);
|
||||
else
|
||||
{
|
||||
if (cbs->action_sublabel(list,
|
||||
entry->type, (unsigned)i,
|
||||
label, path,
|
||||
tmp,
|
||||
sizeof(tmp)))
|
||||
{
|
||||
/* if this function callback returns true,
|
||||
* we know that the value won't change - so we
|
||||
* can cache it instead. */
|
||||
strlcpy(cbs->action_sublabel_cache,
|
||||
tmp, sizeof(cbs->action_sublabel_cache));
|
||||
}
|
||||
|
||||
if (!string_is_empty(tmp))
|
||||
entry->sublabel = strdup(tmp);
|
||||
if (!string_is_empty(tmp))
|
||||
entry->sublabel = strdup(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,8 @@ typedef struct menu_ctx_list
|
||||
|
||||
typedef struct menu_file_list_cbs
|
||||
{
|
||||
char action_sublabel_cache[512];
|
||||
|
||||
enum msg_hash_enums enum_idx;
|
||||
const char *action_iterate_ident;
|
||||
const char *action_deferred_push_ident;
|
||||
|
Loading…
x
Reference in New Issue
Block a user