(menu_displaylist.c) Cut down on strcmp usage

This commit is contained in:
twinaphex 2015-06-05 17:46:50 +02:00
parent a177d55777
commit 9aa35cb938
2 changed files with 20 additions and 15 deletions

View File

@ -19,6 +19,7 @@
#include <file/file_path.h>
#include <file/file_extract.h>
#include <file/dir_list.h>
#include <rhash.h>
#include "menu.h"
#include "menu_display.h"
@ -1106,6 +1107,7 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
bool match_found = false;
struct string_list *tmp_str_list = string_split(
playlist->entries[j].crc32, "|");
uint32_t hash_value = 0;
if (!tmp_str_list)
continue;
@ -1115,20 +1117,22 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
if (tmp_str_list->size > 1)
strlcpy(elem1, tmp_str_list->elems[1].data, sizeof(elem1));
if (!strcmp(elem1, "crc"))
hash_value = djb2_calculate(elem1);
switch (hash_value)
{
if (!strcmp(db_info_entry->crc32, elem0))
match_found = true;
}
else if (!strcmp(elem1, "sha1"))
{
if (!strcmp(db_info_entry->sha1, elem0))
match_found = true;
}
else if (!strcmp(elem1, "md5"))
{
if (!strcmp(db_info_entry->md5, elem0))
match_found = true;
case MENU_VALUE_CRC:
if (!strcmp(db_info_entry->crc32, elem0))
match_found = true;
break;
case MENU_VALUE_SHA1:
if (!strcmp(db_info_entry->sha1, elem0))
match_found = true;
break;
case MENU_VALUE_MD5:
if (!strcmp(db_info_entry->md5, elem0))
match_found = true;
break;
}
string_list_free(tmp_str_list);

View File

@ -174,8 +174,10 @@ extern "C" {
#define MENU_LABEL_VIDEO_SHADER_NUM_PASSES 0x79b2992fU
#define MENU_LABEL_CHEAT_NUM_PASSES 0x1910eb87U
#define MENU_VALUE_MD5 0x0b888fabU
#define MENU_VALUE_SHA1 0x7c9de632U
#define MENU_VALUE_CRC 0x0b88671dU
#define MENU_VALUE_MORE 0x0b877cafU
#define MENU_VALUE_INPUT_SETTINGS 0xddd30846U
#define MENU_VALUE_HORIZONTAL_MENU 0x35761704U
#define MENU_VALUE_MAIN_MENU 0x1625971fU
@ -183,7 +185,6 @@ extern "C" {
#define MENU_VALUE_OFF 0x0b880c40U
#define MENU_VALUE_TRUE 0x7c9e9fe5U
#define MENU_VALUE_FALSE 0x0f6bcef0U
#define MENU_VALUE_COMP 0x6a166ba5U
#define MENU_VALUE_CORE 0x6a167f7fU
#define MENU_VALUE_CURSOR 0x57bba8b4U