git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Stefan Beller <sbeller@google.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Git List <git@vger.kernel.org>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Johannes Schindelin <johannes.schindelin@gmail.com>,
	Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 3/3] submodule: implement `module_clone` as a builtin helper
Date: Tue, 1 Sep 2015 14:35:17 -0400	[thread overview]
Message-ID: <CAPig+cSZ9et=7DNF15MJo-Ef5o1bjbLxAoTgxJV6q1BEUiBGcA@mail.gmail.com> (raw)
In-Reply-To: <CAGZ79kYDYO-q6QEmRQ4YW4ED2HAmMjZNyRaY52ix6YU1=WVNHw@mail.gmail.com>

On Tue, Sep 1, 2015 at 1:49 PM, Stefan Beller <sbeller@google.com> wrote:
> took all suggestions except the one below.
>
>>
>>     if (strbuf_getcwd(&sb))
>>         die_errno(...);
>>     strbuf_addf(&sb, "/%s, sm_gitdir);
>>     free(sm_gitdir);
>>     sm_gitdir = strbuf_detach(&sb, NULL);
>>
>>> +       }
>>> +
>>> +       if (strbuf_getcwd(&sb))
>>> +               die_errno("unable to get current working directory");
>>
>> The conditional block just above here also gets 'cwd'. If you move
>> this code above the !is_absolute_path(sm_gitdir) conditional block,
>> then you can avoid the duplication.
>
> I don't get it. We need to have strbuf_getcwd twice no matter how we
> arrange the code
> as we strbuf_detach will empty the strbuf.
>
> Do you mean to call strbuf_getcwd just once and then xstrdup the value,
> then reset the strbuf to just contain the cwd and append the other string ?

Sorry, I have no idea what you are asking.

All I am saying is that you're unnecessarily invoking getcwd() twice.
It's value doesn't change between invocations, so the second call is
entirely redundant and wasteful. You can instead call it just once and
use the result in both places.

  reply	other threads:[~2015-09-01 18:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 19:19 [PATCHv2 0/3] submodule--helper: Have some refactoring only patches first Stefan Beller
2015-08-31 19:19 ` [PATCH 1/3] submodule: implement `module_list` as a builtin helper Stefan Beller
2015-08-31 21:55   ` Eric Sunshine
2015-08-31 19:19 ` [PATCH 2/3] submodule: implement `module_name` " Stefan Beller
2015-08-31 20:35   ` Junio C Hamano
2015-08-31 20:51     ` Stefan Beller
2015-08-31 22:01   ` Eric Sunshine
2015-08-31 19:19 ` [PATCH 3/3] submodule: implement `module_clone` " Stefan Beller
2015-08-31 22:35   ` Eric Sunshine
2015-09-01 17:49     ` Stefan Beller
2015-09-01 18:35       ` Eric Sunshine [this message]
2015-08-31 20:15 ` [PATCHv2 0/3] submodule--helper: Have some refactoring only patches first Junio C Hamano
2015-09-01  0:40   ` [PATCHv3 " Stefan Beller
2015-09-01  0:40     ` [PATCHv3 1/3] submodule: implement `module-list` as a builtin helper Stefan Beller
2015-09-01  2:22       ` Eric Sunshine
2015-09-01  0:40     ` [PATCHv3 2/3] submodule: implement `module-name` " Stefan Beller
2015-09-01  2:31       ` Eric Sunshine
2015-09-01 16:18         ` Stefan Beller
2015-09-01  0:40     ` [PATCHv3 3/3] submodule: implement `module-clone` " Stefan Beller
2015-09-01  2:41       ` Eric Sunshine
2015-09-01  2:09     ` [PATCHv3 0/3] submodule--helper: Have some refactoring only patches first Eric Sunshine

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CAPig+cSZ9et=7DNF15MJo-Ef5o1bjbLxAoTgxJV6q1BEUiBGcA@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmail.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).