From: Brandon Williams <bmwill@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, sbeller@google.com
Subject: Re: [PATCH 2.5/4] diff: avoid returning a struct by value from diff_flags_or()
Date: Tue, 31 Oct 2017 10:51:19 -0700 [thread overview]
Message-ID: <20171031175119.GB94048@google.com> (raw)
In-Reply-To: <xmqqo9on28mf.fsf@gitster.mtv.corp.google.com>
On 10/31, Junio C Hamano wrote:
> That is more in line with the design decision made in the previous
> step to pass struct by reference.
>
> We may want to squash this into the previous patch eventually.
Looks good to me. I was on the fence with what to do since I was
already moving to pass by reference. This is probably the better move
so I can squash this one into the previous.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
> * I am OK either way as long as things are consistent; as you took
> time to change the code to pass the struct by reference, let's
> unify the API in that direction.
>
> diff-lib.c | 2 +-
> diff.h | 12 ++++--------
> 2 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/diff-lib.c b/diff-lib.c
> index 6c1c05c5b0..ed37f24c68 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -547,7 +547,7 @@ int index_differs_from(const char *def, const struct diff_flags *flags,
> DIFF_OPT_SET(&rev.diffopt, QUICK);
> DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
> if (flags)
> - rev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);
> + diff_flags_or(&rev.diffopt.flags, flags);
> rev.diffopt.ita_invisible_in_index = ita_invisible_in_index;
> run_diff_index(&rev, 1);
> object_array_clear(&rev.pending);
> diff --git a/diff.h b/diff.h
> index 47e6d43cbc..e512cf44d0 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -94,19 +94,15 @@ struct diff_flags {
> unsigned DEFAULT_FOLLOW_RENAMES:1;
> };
>
> -static inline struct diff_flags diff_flags_or(const struct diff_flags *a,
> - const struct diff_flags *b)
> +static inline void diff_flags_or(struct diff_flags *a,
> + const struct diff_flags *b)
> {
> - struct diff_flags out;
> char *tmp_a = (char *)a;
> - char *tmp_b = (char *)b;
> - char *tmp_out = (char *)&out;
> + const char *tmp_b = (const char *)b;
> int i;
>
> for (i = 0; i < sizeof(struct diff_flags); i++)
> - tmp_out[i] = tmp_a[i] | tmp_b[i];
> -
> - return out;
> + tmp_a[i] |= tmp_b[i];
> }
>
> #define DIFF_OPT_TST(opts, flag) ((opts)->flags.flag)
> --
> 2.15.0-224-g5109123e6a
>
--
Brandon Williams
next prev parent reply other threads:[~2017-10-31 17:51 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 22:28 [PATCH 0/3] convert diff flags to be stored in a struct Brandon Williams
2017-10-27 22:28 ` [PATCH 1/3] add: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-27 22:28 ` [PATCH 2/3] reset: " Brandon Williams
2017-10-29 1:26 ` Junio C Hamano
2017-10-30 18:06 ` Brandon Williams
2017-10-27 22:28 ` [PATCH 3/3] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-29 1:55 ` Junio C Hamano
2017-10-30 0:29 ` Junio C Hamano
2017-10-30 19:39 ` Brandon Williams
2017-10-31 2:49 ` Junio C Hamano
2017-10-30 17:49 ` Brandon Williams
2017-10-29 1:22 ` [PATCH 0/3] convert diff flags to be stored in a struct Junio C Hamano
2017-10-29 4:37 ` Stefan Beller
2017-10-30 19:46 ` [PATCH v2 0/4] " Brandon Williams
2017-10-30 19:46 ` [PATCH v2 1/4] add, reset: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-30 19:46 ` [PATCH v2 2/4] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-31 4:41 ` Junio C Hamano
2017-10-31 5:23 ` [PATCH 2.5/4] diff: avoid returning a struct by value from diff_flags_or() Junio C Hamano
2017-10-31 17:51 ` Brandon Williams [this message]
2017-10-30 19:46 ` [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline Brandon Williams
2017-10-30 20:41 ` Stefan Beller
2017-10-30 20:44 ` Brandon Williams
2017-10-30 20:48 ` Brandon Williams
2017-10-31 5:02 ` Junio C Hamano
2017-10-31 5:23 ` [PATCH 3.5/4] diff: set TEXTCONV_VIA_CMDLINE only when it is set to true Junio C Hamano
2017-10-31 17:55 ` Brandon Williams
2017-10-30 19:46 ` [PATCH v2 4/4] diff: remove touched flags Brandon Williams
2017-10-30 22:19 ` [PATCH v2 5/4] diff: remove DIFF_OPT_TST macro Brandon Williams
2017-10-30 22:19 ` [PATCH v2 6/4] diff: remove DIFF_OPT_SET macro Brandon Williams
2017-10-30 22:19 ` [PATCH v2 7/4] diff: remove DIFF_OPT_CLR macro Brandon Williams
2017-10-30 22:19 ` [PATCH v2 8/4] diff: make struct diff_flags members lowercase Brandon Williams
2017-10-31 18:19 ` [PATCH v3 0/8] convert diff flags to be stored in a struct Brandon Williams
2017-10-31 18:19 ` [PATCH v3 1/8] add, reset: use DIFF_OPT_SET macro to set a diff flag Brandon Williams
2017-10-31 18:19 ` [PATCH v3 2/8] diff: convert flags to be stored in bitfields Brandon Williams
2017-10-31 21:32 ` Stefan Beller
2017-11-01 1:26 ` Junio C Hamano
2017-11-01 17:11 ` Stefan Beller
2017-10-31 18:19 ` [PATCH v3 3/8] diff: add flag to indicate textconv was set via cmdline Brandon Williams
2017-10-31 18:19 ` [PATCH v3 4/8] diff: remove touched flags Brandon Williams
2017-10-31 18:19 ` [PATCH v3 5/8] diff: remove DIFF_OPT_TST macro Brandon Williams
2017-10-31 18:19 ` [PATCH v3 6/8] diff: remove DIFF_OPT_SET macro Brandon Williams
2017-10-31 18:19 ` [PATCH v3 7/8] diff: remove DIFF_OPT_CLR macro Brandon Williams
2017-10-31 21:44 ` Stefan Beller
2017-11-01 2:52 ` Junio C Hamano
2017-10-31 18:19 ` [PATCH v3 8/8] diff: make struct diff_flags members lowercase Brandon Williams
2017-10-31 21:46 ` [PATCH v3 0/8] convert diff flags to be stored in a struct Stefan Beller
2017-11-01 6:23 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171031175119.GB94048@google.com \
--to=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).