git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elijah Conners <business@elijahpepe.com>
Cc: "git" <git@vger.kernel.org>, "hanwen" <hanwen@google.com>
Subject: Re: [PATCH] reftable: pass pq_entry by address
Date: Tue, 13 Sep 2022 08:55:55 -0700	[thread overview]
Message-ID: <xmqqbkrjb75g.fsf@gitster.g> (raw)
In-Reply-To: <183353220fe.d7826593472673.3445243727369286065@elijahpepe.com> (Elijah Conners's message of "Mon, 12 Sep 2022 21:53:41 -0700")

Elijah Conners <business@elijahpepe.com> writes:

> In merged_iter_pqueue_add, the pq_entry parameter is passed by value,
> although it exceeds 64 bytes.

Do we have any hard guidance like "do not pass an data item whose
size is larger than 64 bytes" in our coding guidelines?  If not,
make sure that the reference to 64 bytes does not look like one.

While this patch is not bad as a change, we are going to make a copy
of the value with structure assignment at the leaf level, I am not
sure how big a deal this is in practice.

In any case, wouldn't it make sense to make the "we pass reference
not because we want to let the callee modify the value, but because
the callee deep in the callchain wants to copy the contents out of
it" parameter a pointer to a constant?  I.e.

    void merged_iter_pqueue_add(struct merged_iter_pqueue *pq, const struct pq_entry *e)

Other than that, looking good.

  parent reply	other threads:[~2022-09-13 17:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13  4:53 [PATCH] reftable: pass pq_entry by address Elijah Conners
2022-09-13  9:11 ` Han-Wen Nienhuys
2022-09-13 15:55 ` Junio C Hamano [this message]
2022-09-13 17:34   ` Elijah Conners
2022-09-13 17:36     ` Han-Wen Nienhuys
2022-09-13 18:03       ` Elijah Conners
2022-09-15  7:49         ` Han-Wen Nienhuys
2022-09-15  2:27     ` Junio C Hamano
2022-09-14 23:54 ` [PATCH] reftable: use const with the pq_entry param Elijah Conners

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=xmqqbkrjb75g.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=business@elijahpepe.com \
    --cc=git@vger.kernel.org \
    --cc=hanwen@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.
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).