Skip to content

Commit ae15fd4

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b1d30c commit ae15fd4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
17071707
*/
17081708
wt_strategy = use_strategies[i]->name;
17091709

1710-
ret = try_merge_strategy(use_strategies[i]->name,
1710+
ret = try_merge_strategy(wt_strategy,
17111711
common, remoteheads,
17121712
head_commit);
17131713
/*
@@ -1722,12 +1722,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
17221722
* another.
17231723
*/
17241724
merge_was_ok = 1;
1725-
best_strategy = use_strategies[i]->name;
1725+
best_strategy = wt_strategy;
17261726
break;
17271727
}
17281728
cnt = (use_strategies_nr > 1) ? evaluate_result() : 0;
17291729
if (best_cnt <= 0 || cnt <= best_cnt) {
1730-
best_strategy = use_strategies[i]->name;
1730+
best_strategy = wt_strategy;
17311731
best_cnt = cnt;
17321732
}
17331733
}

0 commit comments

Comments
 (0)