merge: small code readability improvement

After our loop through the selected strategies, we compare best_strategy to wt_strategy. This is fine, but the fact that the code setting best_strategy sets it to use_strategies[i]->name requires a little bit of extra checking to determine that at the time of setting, that's the same as wt_strategy. Just setting best_strategy to wt_strategy makes it a little easier to verify what the loop is doing, at least for this reader. Further, use_strategies[i]->name is used in a number of places, where we could just use wt_strategy. The latter takes less time for this reader to parse (one variable name instead of three), so just use wt_strategy to make the code slightly faster for human readers to parse. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Aug 23, 2022 at 02:42 UTC ae15fd4116212d8f2168e321594ee3acc2f50a5f
1 file changed +3 -3
builtin/merge.c
+3 -3
@@ -1707,7 +1707,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1707 */
1708 wt_strategy = use_strategies[i]->name;
1709
1710 - ret = try_merge_strategy(use_strategies[i]->name,
1710 + ret = try_merge_strategy(wt_strategy,
1711 common, remoteheads,
1712 head_commit);
1713 /*
@@ -1722,12 +1722,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1722 * another.
1723 */
1724 merge_was_ok = 1;
1725 - best_strategy = use_strategies[i]->name;
1725 + best_strategy = wt_strategy;
1726 break;
1727 }
1728 cnt = (use_strategies_nr > 1) ? evaluate_result() : 0;
1729 if (best_cnt <= 0 || cnt <= best_cnt) {
1730 - best_strategy = use_strategies[i]->name;
1730 + best_strategy = wt_strategy;
1731 best_cnt = cnt;
1732 }
1733 }