git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge: optimization to skip evaluate_result for single strategy

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2020, 17:23 UTC
Message-ID
<xmqqk11940o9.fsf@gitster.c.googlers.com>
In-Reply-To
<20200518153613.17497-1-anng.sw@gmail.com>
anng.sw@gmail.com writes:
> From: Andrew Ng <andrew.ng@sony.com>
>
> For a merge with a single strategy, the result of evaluate_result() is
> effectively not used and therefore is not needed, so avoid altogether.
Excellent observation.
> On Windows, this optimization can half the time required to perform a
s/half/halve/
Show 17 quoted lines
> recursive merge of a single commit with the LLVM repo.
>
> Signed-off-by: Andrew Ng <andrew.ng@sony.com>
> ---
>  builtin/merge.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index ca6a5dc4bf..7da707bf55 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -1656,7 +1656,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  				}
>  				merge_was_ok = 1;
>  			}
> -			cnt = evaluate_result();
> +			cnt = (use_strategies_nr > 1) ? evaluate_result() : 0;

As best_cnt is initialized to (-1), any value would trigger the logic to nominate the current one as "best so far", and 0 is just as good as it gets ;-) And we'll finish the loop soon after doing so.

Looks good.
>  			if (best_cnt <= 0 || cnt <= best_cnt) {
>  				best_strategy = use_strategies[i]->name;
>  				best_cnt = cnt;
Previous: anng.sw@gmail.com
Message 2 of 2 in “merge: optimization to skip evaluate_result for single strategy”
  1. merge: optimization to skip evaluate_result for single strategyanng.sw@gmail.com, May 18, 2020
  2. Junio C HamanoMay 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.