1 file changed, +6, -11
94820f0refactor(cli): remove str_eq in parse_flags
author
Alex (Oleksii) Haponiuk <git@alexh.dev> on 28-04-2026 15:13 UTC+1
committer
Alex (Oleksii) Haponiuk <git@alexh.dev> on 28-04-2026 15:13 UTC+1
parent6ce58fe
    @@ -6,18 +6,13 @@
 6 6 /*   By: ohaponiu <marvin@42.fr>                    +#+  +:+       +#+        */
 7 7 /*                                                +#+#+#+#+#+   +#+           */
 8 8 /*   Created: 2026/04/23 14:37:52 by ohaponiu          #+#    #+#             */
 9  -/*   Updated: 2026/04/23 16:21:04 by ohaponiu         ###   ########.fr       */
   9+/*   Updated: 2026/04/28 14:43:07 by ohaponiu         ###   ########.fr       */
1010 /*                                                                            */
1111 /* ************************************************************************** */
1212 
1313 #include <cli.h>
1414 #include <libft.h>
1515 
16  -static int	str_eq(const char *a, const char *b)
17  -{
18  -	return (!ft_strncmp(a, b, ft_strlen(b) + 1));
19  -}
20  -
2116 static int	is_flag(const char *arg)
2217 {
2318 	return (arg[0] == '-' && arg[1] == '-');
    @@ -25,13 +20,13 @@ static int	is_flag(const char *arg)
2520 
2621 static int	match_strategy(const char *arg, t_strategy *out)
2722 {
28  -	if (str_eq(arg, "--simple"))
  23+	if (!ft_strncmp(arg, "--simple", 9))
2924 		*out = STRAT_SIMPLE;
30  -	else if (str_eq(arg, "--medium"))
  25+	else if (!ft_strncmp(arg, "--medium", 9))
3126 		*out = STRAT_MEDIUM;
32  -	else if (str_eq(arg, "--complex"))
  27+	else if (!ft_strncmp(arg, "--complex", 10))
3328 		*out = STRAT_COMPLEX;
34  -	else if (str_eq(arg, "--adaptive"))
  29+	else if (!ft_strncmp(arg, "--adaptive", 11))
3530 		*out = STRAT_ADAPTIVE;
3631 	else
3732 		return (0);
    @@ -50,7 +45,7 @@ int	parse_flags(t_flags *flags, int argc, char **argv)
5045 	i = 1;
5146 	while (i < argc && is_flag(argv[i]))
5247 	{
53  -		if (str_eq(argv[i], "--bench"))
  48+		if (!ft_strncmp(argv[i], "--bench", 8))
5449 			flags->bench = 1;
5550 		else if (match_strategy(argv[i], &strat))
5651 		{