From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 394671F545 for ; Mon, 3 Jul 2023 06:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjGCGAG (ORCPT ); Mon, 3 Jul 2023 02:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbjGCGAC (ORCPT ); Mon, 3 Jul 2023 02:00:02 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527A0CA for ; Sun, 2 Jul 2023 22:59:51 -0700 (PDT) Received: (qmail 9368 invoked by uid 109); 3 Jul 2023 05:59:51 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 03 Jul 2023 05:59:51 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 2312 invoked by uid 111); 3 Jul 2023 05:59:53 -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; Mon, 03 Jul 2023 01:59:53 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 3 Jul 2023 01:59:49 -0400 From: Jeff King To: Taylor Blau Cc: git@vger.kernel.org, Chris Torek , Derrick Stolee , Junio C Hamano , Patrick Steinhardt Subject: Re: [PATCH v4 11/16] revision.h: store hidden refs in a `strvec` Message-ID: <20230703055949.GG3502534@coredump.intra.peff.net> References: 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 Tue, Jun 20, 2023 at 10:21:57AM -0400, Taylor Blau wrote: > In subsequent commits, it will be convenient to have a 'const char **' > of hidden refs (matching `transfer.hiderefs`, `uploadpack.hideRefs`, > etc.), instead of a `string_list`. > > Convert spots throughout the tree that store the list of hidden refs > from a `string_list` to a `strvec`. > > Note that in `parse_hide_refs_config()` there is an ugly const-cast used > to avoid an extra copy of each value before trimming any trailing slash > characters. This could instead be written as: > > ref = xstrdup(value); > len = strlen(ref); > while (len && ref[len - 1] == '/') > ref[--len] = '\0'; > strvec_push(hide_refs, ref); > free(ref); > > but the double-copy (once when calling `xstrdup()`, and another via > `strvec_push()`) is wasteful. I saw strvec_push_nodup() suggested here. I'm OK leaving it like this for now, but I do think we'll want that in the long run. -Peff