]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge: break out of all_strategy loop when strategy is found
authorSeija Kijin <doremylover123@gmail.com>
Mon, 9 Jan 2023 17:34:28 +0000 (17:34 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jan 2023 18:24:57 +0000 (10:24 -0800)
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>
builtin/merge.c

index 0f093f2a4f221c2ee22e629cd9e069ee201f268a..74de2ebd2b33f967ff85988779bbf85819fe9a3c 100644 (file)
@@ -188,7 +188,7 @@ static struct strategy *get_strategy(const char *name)
                for (i = 0; i < main_cmds.cnt; i++) {
                        int j, found = 0;
                        struct cmdname *ent = main_cmds.names[i];
-                       for (j = 0; j < ARRAY_SIZE(all_strategy); j++)
+                       for (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)
                                if (!strncmp(ent->name, all_strategy[j].name, ent->len)
                                                && !all_strategy[j].name[ent->len])
                                        found = 1;