git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Martin Ågren" <martin.agren@gmail.com>,
	git@vger.kernel.org, "Emily Shaffer" <emilyshaffer@google.com>
Subject: Re: [PATCH 3/4] grep: simplify color setup
Date: Tue, 24 Nov 2020 01:54:11 -0500	[thread overview]
Message-ID: <X7yuE1M9GpnL0VbT@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqq4klis4zt.fsf@gitster.c.googlers.com>

On Sat, Nov 21, 2020 at 02:46:14PM -0800, Junio C Hamano wrote:

> >>  Come to think of it, I suppose we could copy the whole struct and not
> >>  just the color array. Hmmm...
> >
> > Yes, this seems even better. If our goal is just to start our new
> > grep_opt the same as grep_defaults, then a single-line struct copy
> > (whether through assignment or memcpy) is even clearer and more
> > maintainable.
> 
> ... until such a time when typeof(grep_defaults) gains a field with
> a non-const pointer value that we'd rather not to share amongst
> instances of the type, at which point it no longer is clear win from
> maintainability's point of view.

I don't think we are any worse off. Either way we need to add a
special-case deep copy to the function (which should definitely happen
in only one place; we do not want bare struct copies sprinkled around
the code).

-Peff

  reply	other threads:[~2020-11-24  6:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21 18:31 [PATCH 0/4] grep: retire `init_grep_defaults()` Martin Ågren
2020-11-21 18:31 ` [PATCH 1/4] grep: don't set up a "default" repo for grep Martin Ågren
2020-11-21 18:31 ` [PATCH 2/4] grep: use designated initializers for `grep_defaults` Martin Ågren
2020-11-21 18:31 ` [PATCH 3/4] grep: simplify color setup Martin Ågren
2020-11-21 20:23   ` Jeff King
2020-11-21 20:52     ` Martin Ågren
2020-11-21 22:46     ` Junio C Hamano
2020-11-24  6:54       ` Jeff King [this message]
2020-11-21 18:31 ` [PATCH 4/4] MyFirstObjectWalk: drop `init_walken_defaults()` Martin Ågren
2020-11-23 11:03 ` [PATCH 0/4] grep: retire `init_grep_defaults()` Johannes Schindelin
2020-11-24 21:04 ` [PATCH v2 0/4] grep: simplify "grep defaults" handling Martin Ågren
2020-11-24 21:04   ` [PATCH v2 1/4] grep: don't set up a "default" repo for grep Martin Ågren
2020-11-24 21:04   ` [PATCH v2 2/4] grep: use designated initializers for `grep_defaults` Martin Ågren
2020-11-24 21:04   ` [PATCH v2 3/4] grep: copy struct in one fell swoop Martin Ågren
2020-11-24 22:34     ` Junio C Hamano
2020-11-25  6:25       ` Martin Ågren
2020-11-25  7:53         ` Junio C Hamano
2020-11-26 20:25           ` Martin Ågren
2020-11-24 21:04   ` [PATCH v2 4/4] MyFirstObjectWalk: drop `init_walken_defaults()` Martin Ågren
2020-11-25  9:27   ` [PATCH v2 0/4] grep: simplify "grep defaults" handling Ævar Arnfjörð Bjarmason
2020-11-29 19:52   ` [PATCH v3 " Martin Ågren
2020-11-29 19:52     ` [PATCH v3 1/4] grep: don't set up a "default" repo for grep Martin Ågren
2020-11-29 19:52     ` [PATCH v3 2/4] grep: use designated initializers for `grep_defaults` Martin Ågren
2020-11-29 19:52     ` [PATCH v3 3/4] grep: copy struct in one fell swoop Martin Ågren
2020-11-29 19:52     ` [PATCH v3 4/4] MyFirstObjectWalk: drop `init_walken_defaults()` Martin Ågren
2020-12-01  4:46     ` [PATCH v3 0/4] grep: simplify "grep defaults" handling 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

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

  git send-email \
    --in-reply-to=X7yuE1M9GpnL0VbT@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin.agren@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).