git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 2/7] merge-ort: add a clear_internal_opts helper
Date: Thu, 3 Dec 2020 12:00:26 -0500	[thread overview]
Message-ID: <42a99014-573f-cc5d-ffa0-b22aec288425@gmail.com> (raw)
In-Reply-To: <5d73827b8d6c254f5bc4a99afa421ae34f07182e.1607011187.git.gitgitgadget@gmail.com>

On 12/3/2020 10:59 AM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
> 
> Move most of merge_finalize() into a new helper function,
> clear_internal_opts().  This is a step to facilitate recursive merges,
> as well as some future optimizations.
> 
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  merge-ort.c | 40 ++++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 16 deletions(-)
> 
> diff --git a/merge-ort.c b/merge-ort.c
> index b556897bc0..0654c76c8c 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> @@ -194,6 +194,29 @@ static void free_strmap_strings(struct strmap *map)
>  	}
>  }
>  
> +static void clear_internal_opts(struct merge_options_internal *opti,
> +				int reinitialize)
> +{
> +	assert(!reinitialize);

I was first confused by this new assert, but you are essentially
saying "this parameter doesn't do anything (yet)" which makes sense.

> +
> +	/*
> +	 * We marked opti->paths with strdup_strings = 0, so that we
> +	 * wouldn't have to make another copy of the fullpath created by
> +	 * make_traverse_path from setup_path_info().  But, now that we've
> +	 * used it and have no other references to these strings, it is time
> +	 * to deallocate them.
> +	 */
> +	free_strmap_strings(&opti->paths);
> +	strmap_clear(&opti->paths, 1);
> +
> +	/*
> +	 * All keys and values in opti->conflicted are a subset of those in
> +	 * opti->paths.  We don't want to deallocate anything twice, so we
> +	 * don't free the keys and we pass 0 for free_values.
> +	 */
> +	strmap_clear(&opti->conflicted, 0);
...
> -	/*
> -	 * We marked opti->paths with strdup_strings = 0, so that we
> -	 * wouldn't have to make another copy of the fullpath created by
> -	 * make_traverse_path from setup_path_info().  But, now that we've
> -	 * used it and have no other references to these strings, it is time
> -	 * to deallocate them.
> -	 */
> -	free_strmap_strings(&opti->paths);
> -	strmap_clear(&opti->paths, 1);
> -
> -	/*
> -	 * All keys and values in opti->conflicted are a subset of those in
> -	 * opti->paths.  We don't want to deallocate anything twice, so we
> -	 * don't free the keys and we pass 0 for free_values.
> -	 */
> -	strmap_clear(&opti->conflicted, 0);

the rest of this is a clear code move.

Thanks,
-Stolee

  reply	other threads:[~2020-12-03 17:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 15:59 [PATCH 0/7] merge-ort: some groundwork for further implementation Elijah Newren via GitGitGadget
2020-12-03 15:59 ` [PATCH 1/7] merge-ort: add a few includes Elijah Newren via GitGitGadget
2020-12-03 15:59 ` [PATCH 2/7] merge-ort: add a clear_internal_opts helper Elijah Newren via GitGitGadget
2020-12-03 17:00   ` Derrick Stolee [this message]
2020-12-03 15:59 ` [PATCH 3/7] merge-ort: add a path_conflict field to merge_options_internal Elijah Newren via GitGitGadget
2020-12-03 15:59 ` [PATCH 4/7] merge-ort: add a paths_to_free " Elijah Newren via GitGitGadget
2020-12-03 15:59 ` [PATCH 5/7] merge-ort: add function grouping comments Elijah Newren via GitGitGadget
2020-12-03 15:59 ` [PATCH 6/7] merge-ort: add die-not-implemented stub handle_content_merge() function Elijah Newren via GitGitGadget
2020-12-03 18:40   ` Derrick Stolee
2020-12-03 19:56     ` Elijah Newren
2020-12-03 15:59 ` [PATCH 7/7] merge-ort: add modify/delete handling and delayed output processing Elijah Newren via GitGitGadget
2020-12-04 17:26 ` [PATCH 0/7] merge-ort: some groundwork for further implementation Derrick Stolee
2020-12-04 18:40   ` Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42a99014-573f-cc5d-ffa0-b22aec288425@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).