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.7 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 6DA1C1F4B4 for ; Thu, 10 Sep 2020 19:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbgIJTuf convert rfc822-to-8bit (ORCPT ); Thu, 10 Sep 2020 15:50:35 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:42204 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbgIJTtU (ORCPT ); Thu, 10 Sep 2020 15:49:20 -0400 Received: by mail-ed1-f68.google.com with SMTP id l63so7560100edl.9 for ; Thu, 10 Sep 2020 12:49:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=+sOYINgFCXLhwZt1eg0i6a7v6552cIND0pBZm021SHo=; b=oQeGGPDMol6Z/7rtR6LJih/lX192elMdlhjmSHdvfVLwmrTkfQjmbk30w0hxRlofXT pSogsu681E3nhdiMegUJnJ+HpcemDqEkoeTurrhjRS4OkmOKyBagLSO5GpGm+fqTmcdf K8LOyYtNAP5mFgiH/VzdvPXACctiFICZSx1Kg32kI5HErU9k0NIwZULY5vggi/DdNXW8 O5DMyZqctNkrFPFQFnQ4wsC7SwQwTMEa0AM1yeWGAs75j0B7ScUFFarvKSHGivxFsyYr yIZD+bonztAaJZd6FK90avIH3PtUOdUrkxHVe82DEV8EDWHIO7Rg/0wt4Cy80hiUvqAF hBzg== X-Gm-Message-State: AOAM533BZltmQ21YkKPChYd3RoliDgjZYTW9EQ7Z3sm73z8E4kA2MAOd eCPwPi92FSrdG/qgMJPdxgtDLIHtV6kZThde+DCQkl6jRHY= X-Google-Smtp-Source: ABdhPJx7yAqiOHX9xi9yBM7WI5iZkmBkOw9Z/flgMyP250ge0cc4zXlbt/25NeHT2c19iyS2YgW2OMUv4YnqLERmcrg= X-Received: by 2002:aa7:d15a:: with SMTP id r26mr11123974edo.181.1599767358213; Thu, 10 Sep 2020 12:49:18 -0700 (PDT) MIME-Version: 1.0 References: <58a2469cc18839e57b45f687b6e484d69161a34c.1599762679.git.martin.agren@gmail.com> In-Reply-To: From: Eric Sunshine Date: Thu, 10 Sep 2020 15:49:07 -0400 Message-ID: Subject: Re: [PATCH 4/8] worktree: drop useless call to strbuf_reset To: =?UTF-8?Q?Martin_=C3=85gren?= Cc: Git List , Junio C Hamano Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, Sep 10, 2020 at 3:40 PM Martin Ă…gren wrote: > On Thu, 10 Sep 2020 at 21:15, Eric Sunshine wrote: > > I think this patch is wrong and should be dropped. That strbuf is > > static, and the called strbuf_worktree_ref() does not reset it, so > > each call to worktree_ref() will now merely append to the existing > > content (which is undesirable) following this change. > > That's not to say this optimization won't ever be useful, of course. I > also begin to hope that no caller keeps their returned pointer around > for long. It only seems to be used from `other_ref_heads()` and that > looks ok. If we do want this strbuf reuse, maybe that function could > just keep its own strbuf and reuse it (not necessarily having it be > static) and learn not to call `worktree_ref(wt, "HEAD")` twice. Yep, I wouldn't be unhappy to see worktree_ref() disappear altogether. There are no external callers and it would be easy enough to retrofit the lone internal caller to use the safer strbuf_worktree_ref() anyhow. Plus, both calls to worktree_ref() in other_head_refs() invoke it with the exact same arguments, `worktree_ref(wt, "HEAD")`, which makes one wonder if it need be called twice at all in that particular scenario.