git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Taylor Blau <me@ttaylorr.com>,
	Parth Gala via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Parth Gala <parthpgala@gmail.com>
Subject: Re: [PATCH 2/5] object.c: lookup_unknown_object() accept 'r' as parameter
Date: Thu, 13 Feb 2020 10:00:30 -0800	[thread overview]
Message-ID: <20200213180030.GF45518@syl.local> (raw)
In-Reply-To: <xmqqtv3vtst5.fsf@gitster-ct.c.googlers.com>

On Wed, Feb 12, 2020 at 01:11:02PM -0800, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> writes:
>
> > ... same question about why assigning:
> >
> >   struct repository *r = the_repository;
> >
> > and passing 'r' everywhere is preferable to simply passing
> > 'the_repository' in directly.
> > ...
> >>  static void mark_object_for_connectivity(const struct object_id *oid)
> >>  {
> >> -	struct object *obj = lookup_unknown_object(oid);
> >> +	struct repository *r = the_repository;
> >> +	struct object *obj = lookup_unknown_object(r, oid);
> >>  	obj->flags |= HAS_OBJ;
> >>  }
>
> I do not claim that it applies to this particular function, and the
> function is too small for it to matter, but when a function is large
> enough and it always works on one single repository, it would make
> it easier to later update the function further to set up 'r'
> upfront, making it point at the_repository for now, and to use 'r'
> throughout the function.  That way, when the time comes to update
> the function to work on an arbitrary repository, the only change
> required will be to turn the local variable 'r' to an incoming
> parameter the caller can supply.

Right, but my suggestion was that this advice doesn't apply to this
particular instance since I don't expect that we'd ever passing
something other than 'the_repository'.

Specifically, I was worried that we'd get bitten by re-assigning 'r' in
the middle of the function and then end up in some odd broken state.

Maybe I'm worrying too much.


Thanks,
Taylor

  reply	other threads:[~2020-02-13 18:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 19:19 [PATCH 0/5] object.c: localize global the_repository variable into r Parth Gala via GitGitGadget
2020-02-12 19:19 ` [PATCH 1/5] object.c: get_max_object_index and get_indexed_object accept 'r' parameter Parth Gala via GitGitGadget
2020-02-12 20:22   ` Taylor Blau
2020-02-12 21:13     ` Eric Sunshine
2020-02-13  5:23     ` parth gala
2020-02-12 19:19 ` [PATCH 2/5] object.c: lookup_unknown_object() accept 'r' as parameter Parth Gala via GitGitGadget
2020-02-12 20:25   ` Taylor Blau
2020-02-12 21:11     ` Junio C Hamano
2020-02-13 18:00       ` Taylor Blau [this message]
2020-02-13 18:10         ` Junio C Hamano
2020-02-13 18:52           ` Jeff King
2020-02-15  0:00             ` Taylor Blau
2020-02-12 19:19 ` [PATCH 3/5] object.c: parse_object_or_die() " Parth Gala via GitGitGadget
2020-02-12 19:19 ` [PATCH 4/5] object.c: clear_object_flags() " Parth Gala via GitGitGadget
2020-02-12 19:19 ` [PATCH 5/5] object.c: clear_commit_marks_all() " Parth Gala via GitGitGadget
2020-02-12 20:18 ` [PATCH 0/5] object.c: localize global the_repository variable into r Taylor Blau
2020-02-13  5:14   ` parth gala

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=20200213180030.GF45518@syl.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=parthpgala@gmail.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).