From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id F137B1FA12 for ; Tue, 24 Nov 2020 06:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729833AbgKXGyM (ORCPT ); Tue, 24 Nov 2020 01:54:12 -0500 Received: from cloud.peff.net ([104.130.231.41]:39820 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728986AbgKXGyM (ORCPT ); Tue, 24 Nov 2020 01:54:12 -0500 Received: (qmail 32310 invoked by uid 109); 24 Nov 2020 06:54:12 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 24 Nov 2020 06:54:12 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 11834 invoked by uid 111); 24 Nov 2020 06:54:11 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 24 Nov 2020 01:54:11 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 24 Nov 2020 01:54:11 -0500 From: Jeff King To: Junio C Hamano Cc: Martin =?utf-8?B?w4VncmVu?= , git@vger.kernel.org, Emily Shaffer Subject: Re: [PATCH 3/4] grep: simplify color setup Message-ID: References: <20201121202310.GA972561@coredump.intra.peff.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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