Use memcmp instead of string_is_equal for more instances

This commit is contained in:
twinaphex 2017-04-23 12:17:51 +02:00
parent 1c93cc4b18
commit aea00f1e00
5 changed files with 42 additions and 40 deletions

View File

@ -339,9 +339,9 @@ static void check_variables(void)
if (CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (string_is_equal(var.value, "enabled"))
if (memcmp(var.value, "enabled", 7) == 0)
temporal_interpolation = true;
else if (string_is_equal(var.value, "disabled"))
else if (memcmp(var.value, "disabled", 8) == 0)
temporal_interpolation = false;
}
@ -377,7 +377,7 @@ static void check_variables(void)
colorspace = AVCOL_SPC_BT709;
else if (string_is_equal(color_var.value, "BT.601"))
colorspace = AVCOL_SPC_BT470BG;
else if (string_is_equal(color_var.value, "FCC"))
else if (memcmp(color_var.value, "FCC", 3) == 0)
colorspace = AVCOL_SPC_FCC;
else if (string_is_equal(color_var.value, "SMPTE240M"))
colorspace = AVCOL_SPC_SMPTE240M;

View File

@ -131,7 +131,7 @@ static void salamander_init(char *s, size_t len)
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
config_file_free(conf);
if (!string_is_equal(tmp_str, "builtin"))
if (memcmp(tmp_str, "builtin", 7) != 0)
strlcpy(s, tmp_str, len);
}
#ifdef GEKKO

View File

@ -415,7 +415,7 @@ static uint64_t drm_plane_type(drmModePlane *plane)
for (j = 0; j < props->count_props; j++)
{
/* found the type property */
if (string_is_equal(drmModeGetProperty(drm.fd, props->props[j])->name, "type"))
if (memcmp(drmModeGetProperty(drm.fd, props->props[j])->name, "type", 4) == 0)
return (props->prop_values[j]);
}
return (0);

View File

@ -103,7 +103,7 @@ static JSON_Parser_HandlerResult JSON_CALL StringHandler(JSON_Parser parser, cha
{
if (pValue && length)
{
if (pCtx->cur_field && string_is_equal(pCtx->cur_field, "game_crc"))
if (pCtx->cur_field && memcmp(pCtx->cur_field, "game_crc", 8) == 0)
{
/* CRC comes in as a string but it is stored as an unsigned casted to int */
*((int*)pCtx->cur_member) = (int)strtoul(pValue, NULL, 16);
@ -185,7 +185,7 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
if (!pValue || !length)
return JSON_Parser_Continue;
if (pCtx->state == STATE_OBJECT_START && string_is_equal(pValue, "fields"))
if (pCtx->state == STATE_OBJECT_START && memcmp(pValue, "fields", 6) == 0)
pCtx->state = STATE_FIELDS_START;
if (pCtx->state == STATE_FIELDS_OBJECT_START)
@ -195,46 +195,46 @@ static JSON_Parser_HandlerResult JSON_CALL ObjectMemberHandler(JSON_Parser parse
pCtx->cur_field = strdup(pValue);
if (string_is_equal(pValue, "username"))
if (memcmp(pValue, "username", 8) == 0)
{
pCtx->cur_member = &rooms->cur->nickname;
pCtx->cur_member_size = sizeof(rooms->cur->nickname);
}
else if (string_is_equal(pValue, "game_name"))
else if (memcmp(pValue, "game_name", 9) == 0)
{
pCtx->cur_member = &rooms->cur->gamename;
pCtx->cur_member_size = sizeof(rooms->cur->gamename);
}
else if (string_is_equal(pValue, "core_name"))
else if (memcmp(pValue, "core_name", 9) == 0)
{
pCtx->cur_member = &rooms->cur->corename;
pCtx->cur_member_size = sizeof(rooms->cur->corename);
}
else if (string_is_equal(pValue, "ip"))
else if (memcmp(pValue, "ip", 2) == 0)
{
pCtx->cur_member = &rooms->cur->address;
pCtx->cur_member_size = sizeof(rooms->cur->address);
}
else if (string_is_equal(pValue, "port"))
else if (memcmp(pValue, "port", 4) == 0)
pCtx->cur_member = &rooms->cur->port;
else if (string_is_equal(pValue, "game_crc"))
else if (memcmp(pValue, "game_crc", 8) == 0)
pCtx->cur_member = &rooms->cur->gamecrc;
else if (string_is_equal(pValue, "core_version"))
else if (memcmp(pValue, "core_version", 12) == 0)
{
pCtx->cur_member = &rooms->cur->coreversion;
pCtx->cur_member_size = sizeof(rooms->cur->coreversion);
}
else if (string_is_equal(pValue, "has_password"))
else if (memcmp(pValue, "has_password", 12) == 0)
pCtx->cur_member = &rooms->cur->has_password;
else if (string_is_equal(pValue, "has_spectate_password"))
else if (memcmp(pValue, "has_spectate_password", 21) == 0)
pCtx->cur_member = &rooms->cur->has_spectate_password;
else if (string_is_equal(pValue, "fixed"))
else if (memcmp(pValue, "fixed", 5) == 0)
pCtx->cur_member = &rooms->cur->fixed;
else if (string_is_equal(pValue, "mitm_ip"))
else if (memcmp(pValue, "mitm_ip", 7) == 0)
pCtx->cur_member = &rooms->cur->mitm_address;
else if (string_is_equal(pValue, "mitm_port"))
else if (memcmp(pValue, "mitm_port", 9) == 0)
pCtx->cur_member = &rooms->cur->mitm_port;
else if (string_is_equal(pValue, "host_method"))
else if (memcmp(pValue, "host_method", 11) == 0)
pCtx->cur_member = &rooms->cur->host_method;
else
{

View File

@ -17,6 +17,7 @@
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <retro_miscellaneous.h>
#include <compat/strcasestr.h>
@ -276,31 +277,32 @@ int detect_psp_game(const char *track_path, char *game_id)
if (filestream_read(fd, game_id, 5) > 0)
{
game_id[5] = '\0';
if (string_is_equal(game_id, "ULES-")
|| string_is_equal(game_id, "ULUS-")
|| string_is_equal(game_id, "ULJS-")
if (
(memcmp(game_id, "ULES-", 5) == 0)
|| (memcmp(game_id, "ULUS-", 5) == 0)
|| (memcmp(game_id, "ULJS-", 5) == 0)
|| string_is_equal(game_id, "ULEM-")
|| string_is_equal(game_id, "ULUM-")
|| string_is_equal(game_id, "ULJM-")
|| (memcmp(game_id, "ULEM-", 5) == 0)
|| (memcmp(game_id, "ULUM-", 5) == 0)
|| (memcmp(game_id, "ULJM-", 5) == 0)
|| string_is_equal(game_id, "UCES-")
|| string_is_equal(game_id, "UCUS-")
|| string_is_equal(game_id, "UCJS-")
|| string_is_equal(game_id, "UCAS-")
|| (memcmp(game_id, "UCES-", 5) == 0)
|| (memcmp(game_id, "UCUS-", 5) == 0)
|| (memcmp(game_id, "UCJS-", 5) == 0)
|| (memcmp(game_id, "UCAS-", 5) == 0)
|| string_is_equal(game_id, "NPEH-")
|| string_is_equal(game_id, "NPUH-")
|| string_is_equal(game_id, "NPJH-")
|| (memcmp(game_id, "NPEH-", 5) == 0)
|| (memcmp(game_id, "NPUH-", 5) == 0)
|| (memcmp(game_id, "NPJH-", 5) == 0)
|| string_is_equal(game_id, "NPEG-")
|| string_is_equal(game_id, "NPUG-")
|| string_is_equal(game_id, "NPJG-")
|| string_is_equal(game_id, "NPHG-")
|| (memcmp(game_id, "NPEG-", 5) == 0)
|| (memcmp(game_id, "NPUG-", 5) == 0)
|| (memcmp(game_id, "NPJG-", 5) == 0)
|| (memcmp(game_id, "NPHG-", 5) == 0)
|| string_is_equal(game_id, "NPEZ-")
|| string_is_equal(game_id, "NPUZ-")
|| string_is_equal(game_id, "NPJZ-")
|| (memcmp(game_id, "NPEZ-", 5) == 0)
|| (memcmp(game_id, "NPUZ-", 5) == 0)
|| (memcmp(game_id, "NPJZ-", 5) == 0)
)
{
filestream_seek(fd, pos, SEEK_SET);