merge: break out of all_strategy loop when strategy is found
Once we find a match, there is no point to try finding the second match in the inner loop. Break out of the loop once we find the first match. Signed-off-by: Seija Kijin <doremylover123@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Seija Kijin committed
Jan 9, 2023 at 17:34 UTC
0c75692ebcddb2443c5e56c68c2e0ed55dd1ae18
1 file changed
+1
-1
builtin/merge.c
+1
-1
@@ -188,7 +188,7 @@ static struct strategy *get_strategy(const char *name)
188
for (i = 0; i < main_cmds.cnt; i++) {
189
int j, found = 0;
190
struct cmdname *ent = main_cmds.names[i];
191
- for (j = 0; j < ARRAY_SIZE(all_strategy); j++)
191
+ for (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)
192
if (!strncmp(ent->name, all_strategy[j].name, ent->len)
193
&& !all_strategy[j].name[ent->len])
194
found = 1;