Skip to content

Commit 7f53f79

Browse files
committed
* less stdstring dependencies
* replace string_is_equal with memcmp
1 parent 9ff2c85 commit 7f53f79

File tree

16 files changed

+172
-165
lines changed

16 files changed

+172
-165
lines changed

gfx/gfx_animation.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <encodings/utf.h>
2222
#include <retro_math.h>
2323
#include <retro_miscellaneous.h>
24-
#include <string/stdstring.h>
2524
#include <features/features_cpu.h>
2625
#include <array/rbuf.h>
2726

@@ -1314,7 +1313,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
13141313
gfx_animation_t *p_anim = &anim_st;
13151314

13161315
/* Sanity check */
1317-
if ( string_is_empty(ticker->src_str)
1316+
if ( (!ticker->src_str || !*ticker->src_str)
13181317
|| (ticker->dst_str_len < 1)
13191318
|| (ticker->field_width < 1)
13201319
|| (!ticker->font && (ticker->glyph_width < 1)))

gfx/video_driver.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -612,31 +612,31 @@ const char *hw_render_context_name(
612612
static enum retro_hw_context_type hw_render_context_type(const char *s)
613613
{
614614
#ifdef HAVE_OPENGL_CORE
615-
if (string_is_equal(s, "glcore"))
615+
if (memcmp(s, "glcore", 7) == 0)
616616
return RETRO_HW_CONTEXT_OPENGL_CORE;
617617
#endif
618618
#ifdef HAVE_OPENGL
619-
if (string_is_equal(s, "gl"))
619+
if (memcmp(s, "gl", 3) == 0)
620620
return RETRO_HW_CONTEXT_OPENGL;
621621
#endif
622622
#ifdef HAVE_VULKAN
623-
if (string_is_equal(s, "vulkan"))
623+
if (memcmp(s, "vulkan", 7) == 0)
624624
return RETRO_HW_CONTEXT_VULKAN;
625625
#endif
626626
#if defined(HAVE_D3D9) && defined(HAVE_HLSL)
627-
if (string_is_equal(s, "d3d9_hlsl"))
627+
if (memcmp(s, "d3d9_hlsl", 10) == 0)
628628
return RETRO_HW_CONTEXT_D3D9;
629629
#endif
630630
#ifdef HAVE_D3D10
631-
if (string_is_equal(s, "d3d10"))
631+
if (memcmp(s, "d3d10", 6) == 0)
632632
return RETRO_HW_CONTEXT_D3D10;
633633
#endif
634634
#ifdef HAVE_D3D11
635-
if (string_is_equal(s, "d3d11"))
635+
if (memcmp(s, "d3d11", 6) == 0)
636636
return RETRO_HW_CONTEXT_D3D11;
637637
#endif
638638
#ifdef HAVE_D3D12
639-
if (string_is_equal(s, "d3d12"))
639+
if (memcmp(s, "d3d12", 6) == 0)
640640
return RETRO_HW_CONTEXT_D3D12;
641641
#endif
642642
return RETRO_HW_CONTEXT_NONE;
@@ -3170,7 +3170,7 @@ void video_driver_build_info(video_frame_info_t *video_info)
31703170
* frameskip target to make it smoother and faster. */
31713171
if ( video_info->fullscreen
31723172
&& settings->bools.video_vsync
3173-
&& string_is_equal(video_driver_get_ident(), "vulkan"))
3173+
&& (memcmp(video_driver_get_ident(), "vulkan", 6) == 0))
31743174
video_info->frame_time_target /= 2.0f;
31753175
#endif
31763176
#endif
@@ -3400,40 +3400,37 @@ enum gfx_ctx_api video_context_driver_get_api(void)
34003400
enum gfx_ctx_api ctx_api = ctx_data
34013401
? ctx->get_api(ctx_data)
34023402
: GFX_CTX_NONE;
3403-
34043403
if (ctx_api == GFX_CTX_NONE)
34053404
{
34063405
const char *video_ident = (vid) ? vid->ident : NULL;
34073406
if (string_starts_with_size(video_ident, "d3d", STRLEN_CONST("d3d")))
34083407
{
3409-
if (string_is_equal(video_ident, "d3d9_hlsl"))
3408+
if (!memcmp(video_ident, "d3d9_hlsl", STRLEN_CONST("d3d9_hlsl") + 1))
34103409
return GFX_CTX_DIRECT3D9_API;
3411-
else if (string_is_equal(video_ident, "d3d10"))
3410+
else if (!memcmp(video_ident, "d3d10", STRLEN_CONST("d3d10") + 1))
34123411
return GFX_CTX_DIRECT3D10_API;
3413-
else if (string_is_equal(video_ident, "d3d11"))
3412+
else if (!memcmp(video_ident, "d3d11", STRLEN_CONST("d3d11") + 1))
34143413
return GFX_CTX_DIRECT3D11_API;
3415-
else if (string_is_equal(video_ident, "d3d12"))
3414+
else if (!memcmp(video_ident, "d3d12", STRLEN_CONST("d3d12") + 1))
34163415
return GFX_CTX_DIRECT3D12_API;
34173416
}
34183417
if (string_starts_with_size(video_ident, "gl", STRLEN_CONST("gl")))
34193418
{
3420-
if (string_is_equal(video_ident, "gl"))
3419+
if (!memcmp(video_ident, "gl", STRLEN_CONST("gl") + 1))
34213420
return GFX_CTX_OPENGL_API;
3422-
else if (string_is_equal(video_ident, "gl1"))
3421+
else if (!memcmp(video_ident, "gl1", STRLEN_CONST("gl1") + 1))
34233422
return GFX_CTX_OPENGL_API;
3424-
else if (string_is_equal(video_ident, "glcore"))
3423+
else if (!memcmp(video_ident, "glcore", STRLEN_CONST("glcore") + 1))
34253424
return GFX_CTX_OPENGL_API;
34263425
}
3427-
else if (string_is_equal(video_ident, "vulkan"))
3426+
else if (!memcmp(video_ident, "vulkan", STRLEN_CONST("vulkan") + 1))
34283427
return GFX_CTX_VULKAN_API;
3429-
else if (string_is_equal(video_ident, "metal"))
3428+
else if (!memcmp(video_ident, "metal", STRLEN_CONST("metal") + 1))
34303429
return GFX_CTX_METAL_API;
3431-
else if (string_is_equal(video_ident, "rsx"))
3430+
else if (!memcmp(video_ident, "rsx", STRLEN_CONST("rsx") + 1))
34323431
return GFX_CTX_RSX_API;
3433-
34343432
return GFX_CTX_NONE;
34353433
}
3436-
34373434
return ctx_api;
34383435
}
34393436

gfx/video_shader_parse.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,14 @@ static const char *video_shader_wrap_mode_to_str(enum gfx_wrap_type type)
565565
**/
566566
static enum gfx_wrap_type video_shader_wrap_str_to_mode(const char *wrap_mode)
567567
{
568-
if (string_is_equal(wrap_mode, "clamp_to_border"))
568+
if (memcmp(wrap_mode, "clamp_to_border", sizeof("clamp_to_border")) == 0)
569569
return RARCH_WRAP_BORDER;
570-
else if (string_is_equal(wrap_mode, "clamp_to_edge"))
570+
else if (memcmp(wrap_mode, "clamp_to_edge", sizeof("clamp_to_edge")) == 0)
571571
return RARCH_WRAP_EDGE;
572-
else if (string_is_equal(wrap_mode, "repeat"))
572+
else if (memcmp(wrap_mode, "repeat", sizeof("repeat")) == 0)
573573
return RARCH_WRAP_REPEAT;
574-
else if (string_is_equal(wrap_mode, "mirrored_repeat"))
574+
else if (memcmp(wrap_mode, "mirrored_repeat", sizeof("mirrored_repeat")) == 0)
575575
return RARCH_WRAP_MIRRORED_REPEAT;
576-
577576
RARCH_WARN("[Shaders] Invalid wrapping type \"%s\". Valid ones are: \"clamp_to_border\" "
578577
"(default), \"clamp_to_edge\", \"repeat\" and \"mirrored_repeat\". Falling back to default.\n",
579578
wrap_mode);
@@ -714,11 +713,11 @@ static bool video_shader_parse_pass(config_file_t *conf,
714713

715714
if (*scale_type_x)
716715
{
717-
if (string_is_equal(scale_type_x, "source"))
716+
if (memcmp(scale_type_x, "source", 7) == 0)
718717
scale->type_x = RARCH_SCALE_INPUT;
719-
else if (string_is_equal(scale_type_x, "viewport"))
718+
else if (memcmp(scale_type_x, "viewport", 9) == 0)
720719
scale->type_x = RARCH_SCALE_VIEWPORT;
721-
else if (string_is_equal(scale_type_x, "absolute"))
720+
else if (memcmp(scale_type_x, "absolute", 9) == 0)
722721
scale->type_x = RARCH_SCALE_ABSOLUTE;
723722
else
724723
{
@@ -729,11 +728,11 @@ static bool video_shader_parse_pass(config_file_t *conf,
729728

730729
if (*scale_type_y)
731730
{
732-
if (string_is_equal(scale_type_y, "source"))
731+
if (memcmp(scale_type_y, "source", sizeof("source")) == 0)
733732
scale->type_y = RARCH_SCALE_INPUT;
734-
else if (string_is_equal(scale_type_y, "viewport"))
733+
else if (memcmp(scale_type_y, "viewport", sizeof("viewport")) == 0)
735734
scale->type_y = RARCH_SCALE_VIEWPORT;
736-
else if (string_is_equal(scale_type_y, "absolute"))
735+
else if (memcmp(scale_type_y, "absolute", sizeof("absolute")) == 0)
737736
scale->type_y = RARCH_SCALE_ABSOLUTE;
738737
else
739738
{

input/drivers_joypad/dinput_joypad.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include <boolean.h>
2727
#include <compat/strl.h>
28-
#include <string/stdstring.h>
2928

3029
#ifdef HAVE_CONFIG_H
3130
#include "../../config.h"

input/drivers_joypad/linuxraw_joypad.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ static bool linuxraw_joypad_init_pad(const char *path,
114114

115115
static const char *linuxraw_joypad_name(unsigned pad)
116116
{
117-
if (pad >= MAX_USERS || string_is_empty(linuxraw_pads[pad].ident))
117+
if (pad >= MAX_USERS)
118118
return NULL;
119-
120119
return linuxraw_pads[pad].ident;
121120
}
122121

input/drivers_joypad/xinput_hybrid_joypad.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <retro_inline.h>
3737
#include <compat/strl.h>
3838
#include <dynamic/dylib.h>
39-
#include <string/stdstring.h>
4039

4140
#ifdef HAVE_CONFIG_H
4241
#include "../../config.h"

input/drivers_joypad/xinput_joypad.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <retro_inline.h>
3131
#include <compat/strl.h>
3232
#include <dynamic/dylib.h>
33-
#include <string/stdstring.h>
3433

3534
#ifdef HAVE_CONFIG_H
3635
#include "../../config.h"

input/input_driver.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,6 @@ static bool input_keyboard_line_event(
45644564
return ret;
45654565
}
45664566

4567-
45684567
void input_event_osk_append(
45694568
input_keyboard_line_t *keyboard_line,
45704569
enum osk_type *osk_idx,
@@ -4576,54 +4575,53 @@ void input_event_osk_append(
45764575
size_t len)
45774576
{
45784577
#ifdef HAVE_LANGEXTRA
4579-
if (string_is_equal(word, "\xe2\x87\xa6")) /* backspace character */
4578+
if (memcmp(word, "\xe2\x87\xa6", 4) == 0) /* backspace character */
45804579
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
4581-
else if (string_is_equal(word, "\xe2\x8f\x8e")) /* return character */
4580+
else if (memcmp(word, "\xe2\x8f\x8e", 4) == 0) /* return character */
45824581
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
4583-
else
4584-
if (string_is_equal(word, "\xe2\x87\xa7")) /* up arrow */
4582+
else if (memcmp(word, "\xe2\x87\xa7", 4) == 0) /* up arrow */
45854583
*osk_idx = OSK_UPPERCASE_LATIN;
4586-
else if (string_is_equal(word, "\xe2\x87\xa9")) /* down arrow */
4584+
else if (memcmp(word, "\xe2\x87\xa9", 4) == 0) /* down arrow */
45874585
*osk_idx = OSK_LOWERCASE_LATIN;
4588-
else if (string_is_equal(word,"\xe2\x8a\x95")) /* plus sign (next button) */
4586+
else if (memcmp(word, "\xe2\x8a\x95", 4) == 0) /* plus sign (next button) */
45894587
{
4590-
if (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE) == RETRO_LANGUAGE_KOREAN )
4588+
if (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE) == RETRO_LANGUAGE_KOREAN)
45914589
{
4592-
static int prv_osk = OSK_TYPE_UNKNOWN+1;
4593-
if (*osk_idx < OSK_KOREAN_PAGE1 )
4590+
static int prv_osk = OSK_TYPE_UNKNOWN + 1;
4591+
if (*osk_idx < OSK_KOREAN_PAGE1)
45944592
{
45954593
prv_osk = *osk_idx;
4596-
*osk_idx = OSK_KOREAN_PAGE1;
4594+
*osk_idx = OSK_KOREAN_PAGE1;
45974595
}
45984596
else
45994597
*osk_idx = (enum osk_type)prv_osk;
46004598
}
4601-
else
4602-
if (*osk_idx < (show_symbol_pages ? OSK_TYPE_LAST - 1 : OSK_SYMBOLS_PAGE1))
4599+
else if (*osk_idx < (show_symbol_pages ? OSK_TYPE_LAST - 1 : OSK_SYMBOLS_PAGE1))
46034600
*osk_idx = (enum osk_type)(*osk_idx + 1);
46044601
else
4605-
*osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1));
4602+
*osk_idx = (enum osk_type)(OSK_TYPE_UNKNOWN + 1);
46064603
}
46074604
else if (*osk_idx == OSK_KOREAN_PAGE1 && word && len == 3)
46084605
{
46094606
unsigned character = *((unsigned*)word) | 0x01000000;
4610-
input_keyboard_line_event(&input_driver_st, keyboard_line, character);
4607+
input_keyboard_line_event(&input_driver_st, keyboard_line, character);
46114608
}
46124609
#else
4613-
if (string_is_equal(word, "Bksp"))
4610+
if (memcmp(word, "Bksp", 5) == 0)
46144611
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
4615-
else if (string_is_equal(word, "Enter"))
4612+
else if (memcmp(word, "Enter", 6) == 0)
46164613
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
4617-
else
4618-
if (string_is_equal(word, "Upper"))
4614+
else if (memcmp(word, "Upper", 6) == 0)
46194615
*osk_idx = OSK_UPPERCASE_LATIN;
4620-
else if (string_is_equal(word, "Lower"))
4616+
else if (memcmp(word, "Lower", 6) == 0)
46214617
*osk_idx = OSK_LOWERCASE_LATIN;
4622-
else if (string_is_equal(word, "Next"))
4618+
else if (memcmp(word, "Next", 5) == 0)
4619+
{
46234620
if (*osk_idx < (show_symbol_pages ? OSK_TYPE_LAST - 1 : OSK_SYMBOLS_PAGE1))
46244621
*osk_idx = (enum osk_type)(*osk_idx + 1);
46254622
else
4626-
*osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1));
4623+
*osk_idx = (enum osk_type)(OSK_TYPE_UNKNOWN + 1);
4624+
}
46274625
#endif
46284626
else
46294627
{

libretro-common/formats/xml/rxml.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23+
#include <string.h>
24+
2325
#include <boolean.h>
2426
#include <streams/file_stream.h>
2527
#include <compat/posix_string.h>
26-
#include <string/stdstring.h>
2728

2829
#include <formats/rxml.h>
2930

@@ -321,7 +322,7 @@ const char *rxml_node_attrib(struct rxml_node *node, const char *attrib)
321322
struct rxml_attrib_node *attribs = NULL;
322323
for (attribs = node->attrib; attribs; attribs = attribs->next)
323324
{
324-
if (string_is_equal(attrib, attribs->attrib))
325+
if (strcmp(attrib, attribs->attrib) == 0)
325326
return attribs->value;
326327
}
327328

msg_hash.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
* If not, see <http://www.gnu.org/licenses/>.
1515
*/
1616

17-
#include <stdio.h>
17+
#include <stdlib.h>
1818
#include <string.h>
1919

20+
#include <compat/strl.h>
21+
#include <string/stdstring.h> /* for string_replace_substring */
2022
#include <lrc_hash.h>
21-
#include <string/stdstring.h>
2223
#include <libretro.h>
2324

2425
#ifdef HAVE_CONFIG_H
@@ -43,8 +44,8 @@ int msg_hash_get_help_enum(enum msg_hash_enums msg, char *s, size_t len)
4344
int ret = msg_hash_get_help_us_enum(msg, s, len);
4445
/* Replace line-breaks with "empty line-breaks" for readability */
4546
const char *temp = string_replace_substring(s, strlen(s),
46-
"\n", STRLEN_CONST("\n"),
47-
"\n \n", STRLEN_CONST("\n \n"));
47+
"\n", (sizeof("\n")-1),
48+
"\n \n", (sizeof("\n \n")-1));
4849

4950
if (temp)
5051
{
@@ -699,10 +700,8 @@ const char *msg_hash_to_str(enum msg_hash_enums msg)
699700
break;
700701
}
701702
#endif
702-
703-
if (ret && !string_is_equal(ret, "null"))
703+
if (ret && strcmp(ret, "null") != 0)
704704
return ret;
705-
706705
return msg_hash_to_str_us(msg);
707706
}
708707

0 commit comments

Comments
 (0)