Re: [PATCH 3/4] grep: simplify color setup
- From
Jeff King <peff@peff.net>
- Date
- Nov 24, 2020, 06:54 UTC
- Message-ID
- <X7yuE1M9GpnL0VbT@coredump.intra.peff.net>
- In-Reply-To
- <xmqq4klis4zt.fsf@gitster.c.googlers.com>
On Sat, Nov 21, 2020 at 02:46:14PM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> >> 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