Skip to content

Commit df617a3

Browse files
committed
retroarch_parse_input - RA_OPT_SIZE no longer uses sscanf - up
to 4-5x faster
1 parent 9b20bbd commit df617a3

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

retroarch.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7725,12 +7725,27 @@ static bool retroarch_parse_input_and_config(
77257725
break;
77267726

77277727
case RA_OPT_SIZE:
7728-
if (sscanf(optarg, "%ux%u",
7729-
&rec_st->width, &rec_st->height) != 2)
77307728
{
7731-
RARCH_ERR("Wrong format for --size.\n");
7732-
retroarch_print_help(argv[0]);
7733-
retroarch_fail(1, "retroarch_parse_input()");
7729+
char *sep;
7730+
unsigned long w = (unsigned long)strtoul(optarg, &sep, 0);
7731+
if (sep == optarg || *sep != 'x')
7732+
{
7733+
RARCH_ERR("Wrong format for --size.\n");
7734+
retroarch_print_help(argv[0]);
7735+
retroarch_fail(1, "retroarch_parse_input()");
7736+
}
7737+
{
7738+
char *end;
7739+
unsigned long h = (unsigned long)strtoul(sep + 1, &end, 0);
7740+
if (end == sep + 1 || *end != '\0')
7741+
{
7742+
RARCH_ERR("Wrong format for --size.\n");
7743+
retroarch_print_help(argv[0]);
7744+
retroarch_fail(1, "retroarch_parse_input()");
7745+
}
7746+
rec_st->width = (unsigned)w;
7747+
rec_st->height = (unsigned)h;
7748+
}
77347749
}
77357750
break;
77367751

0 commit comments

Comments
 (0)