From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] fetch-pack: do not reset in_vain on non-novel acks
Date: Fri, 23 Sep 2016 12:40:12 -0700 [thread overview]
Message-ID: <xmqq1t0a1k2r.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1474652495-26051-1-git-send-email-jonathantanmy@google.com> (Jonathan Tan's message of "Fri, 23 Sep 2016 10:41:35 -0700")
Jonathan Tan <jonathantanmy@google.com> writes:
> I tried looking at creating a helper function to reduce both the size
> and the nesting level of the loop, but it seems to me that a helper
> function can't be extracted so easily because the logic is quite
> intertwined with the rest of the function. For example, the "if
> (args->stateless_rpc..." block uses 6 variables from the outer scope:
> args, ack, commit, result_sha1, req_buf, and state_len (and in_vain, but
> this can be the return value of the function). Expanding it wider would
> allow us to make some of those 6 local, but also introduce new ones from
> the outer scope.
Yup, I suspected that much when I wrote the message you are
responding to, but was sort-of hoping that you might come up with a
more clever way to restructure the code. It is OK to leave it
as-is, and let others try making it cleaner ;-).
Thanks.
>
> fetch-pack.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 85e77af..413937e 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -428,10 +428,17 @@ static int find_common(struct fetch_pack_args *args,
> const char *hex = sha1_to_hex(result_sha1);
> packet_buf_write(&req_buf, "have %s\n", hex);
> state_len = req_buf.len;
> - }
> + /*
> + * Reset in_vain because an ack
> + * for this commit has not been
> + * seen.
> + */
> + in_vain = 0;
> + } else if (!args->stateless_rpc
> + || ack != ACK_common)
> + in_vain = 0;
> mark_common(commit, 0, 1);
> retval = 0;
> - in_vain = 0;
> got_continue = 1;
> if (ack == ACK_ready) {
> clear_prio_queue(&rev_list);
next prev parent reply other threads:[~2016-09-23 19:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 18:36 [PATCH] do not reset in_vain on non-novel acks Jonathan Tan
2016-09-22 18:36 ` [PATCH] fetch-pack: " Jonathan Tan
2016-09-22 20:05 ` Junio C Hamano
2016-09-23 17:41 ` [PATCH v2] " Jonathan Tan
2016-09-23 19:40 ` Junio C Hamano [this message]
2016-09-22 19:20 ` [PATCH] " Junio C Hamano
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=xmqq1t0a1k2r.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@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).