mirror of
https://github.com/libretro/RetroArch
synced 2025-03-21 04:21:13 +00:00
Merge pull request #1786 from heuripedes/master
(menu_setting.c) Speed up setting lookup using hashes
This commit is contained in:
commit
a7ad10f884
@ -63,6 +63,8 @@ static bool menu_settings_list_append(rarch_setting_t **list,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value.name_hash = value.name ? djb2_calculate(value.name) : 0;
|
||||||
|
|
||||||
(*list)[list_info->index++] = value;
|
(*list)[list_info->index++] = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -308,16 +310,23 @@ static rarch_setting_t *menu_setting_get_ptr(void)
|
|||||||
rarch_setting_t *menu_setting_find(const char *label)
|
rarch_setting_t *menu_setting_find(const char *label)
|
||||||
{
|
{
|
||||||
rarch_setting_t *settings = menu_setting_get_ptr();
|
rarch_setting_t *settings = menu_setting_get_ptr();
|
||||||
|
uint32_t needle = 0;
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!label)
|
if (!label)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
needle = djb2_calculate(label);
|
||||||
|
|
||||||
for (; settings->type != ST_NONE; settings++)
|
for (; settings->type != ST_NONE; settings++)
|
||||||
{
|
{
|
||||||
if (settings->type <= ST_GROUP && !strcmp(settings->name, label))
|
if (settings->type <= ST_GROUP && needle == settings->name_hash)
|
||||||
{
|
{
|
||||||
|
/* make sure this isn't a collision */
|
||||||
|
if (strcmp(label, settings->name) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (settings->short_description && settings->short_description[0] == '\0')
|
if (settings->short_description && settings->short_description[0] == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -131,6 +131,7 @@ typedef struct rarch_setting
|
|||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
const char *name;
|
const char *name;
|
||||||
|
uint32_t name_hash;
|
||||||
const char *short_description;
|
const char *short_description;
|
||||||
const char *group;
|
const char *group;
|
||||||
const char *subgroup;
|
const char *subgroup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user