From: Junio C Hamano <gitster@pobox.com>
To: Alex Henrie <alexhenrie24@gmail.com>
Cc: git@vger.kernel.org, dstolee@microsoft.com,
Derrick Stolee <stolee@gmail.com>
Subject: Re: [PATCH v3] commit-graph: remove a duplicate assignment
Date: Mon, 30 Sep 2019 10:22:44 +0900 [thread overview]
Message-ID: <xmqqimpainmj.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190929005558.733699-1-alexhenrie24@gmail.com> (Alex Henrie's message of "Sat, 28 Sep 2019 18:55:58 -0600")
Alex Henrie <alexhenrie24@gmail.com> writes:
> The variable g was being set to the same value both at the beginning of
> the function and before the loop. The assignment before the loop was
> kept because it helps clarify what the loop does, and the redundant
> assignment at the beginning of the function was removed.
Writing these mostly in the past tense is misleading to those who
are used to read "git log" from this project. Give orders to the
codebase to "become like so" instead. Perhaps like
Leave the variable 'g' uninitialized before it is set just
before its first use in front of a loop, which is a lot more
appropriate place to indicate what it is used for.
> static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
> {
> - struct commit_graph *g = ctx->r->objects->commit_graph;
> + struct commit_graph *g;
> uint32_t num_commits = ctx->commits.nr;
Stepping back a bit, doesn't the same justification you gave to this
change apply to 'num_commits'? If you make it uninitialized before
its first use and assign ctx->commits.nr to it near where 'g' is
given its first value, wouldn't it make it even clearer that these
two variables are almost always used together and how they are used
in the loop?
next prev parent reply other threads:[~2019-09-30 1:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-29 0:55 [PATCH v3] commit-graph: remove a duplicate assignment Alex Henrie
2019-09-30 1:22 ` Junio C Hamano [this message]
2019-09-30 7:34 ` Alex Henrie
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqimpainmj.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=alexhenrie24@gmail.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=stolee@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.
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 NNTP newsgroup(s).