(Menu) Cut down on strcmp usage in menu_input.c

This commit is contained in:
twinaphex 2015-06-05 17:56:51 +02:00
parent 6f1e5a81be
commit d6a17a97de
2 changed files with 21 additions and 7 deletions

View File

@ -2109,7 +2109,8 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list)
const char *label = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
menu_displaylist_info_t info = {0};
uint32_t hash_value = djb2_calculate(label);
uint32_t hash_value = 0;
menu_list_get_last_stack(menu->menu_list, &path, &label, &type);
@ -2119,6 +2120,8 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list)
strlcpy(info.path, path, sizeof(info.path));
strlcpy(info.label, label, sizeof(info.label));
hash_value = djb2_calculate(label);
return menu_displaylist_deferred_push(&info, hash_value);
}

View File

@ -22,6 +22,9 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <rhash.h>
#include "menu_input.h"
#include "menu.h"
#include "menu_entry.h"
@ -135,12 +138,20 @@ void menu_input_st_string_callback(void *userdata, const char *str)
}
else
{
if (!strcmp(menu->keyboard.label_setting, "video_shader_preset_save_as"))
uint32_t hash_label = djb2_calculate(menu->keyboard.label_setting);
switch (hash_label)
{
case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS:
menu_shader_manager_save_preset(str, false);
else if (!strcmp(menu->keyboard.label_setting, "remap_file_save_as"))
break;
case MENU_LABEL_REMAP_FILE_SAVE_AS:
input_remapping_save_file(str);
else if (!strcmp(menu->keyboard.label_setting, "cheat_file_save_as"))
break;
case MENU_LABEL_CHEAT_FILE_SAVE_AS:
cheat_manager_save(global->cheat, str);
break;
}
}
}