All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 1/3] csum-file: add hashwrite_be64()
Date: Thu, 12 Nov 2020 09:51:12 -0500	[thread overview]
Message-ID: <X61L4Ebd5PBpYDel@nand.local> (raw)
In-Reply-To: <16932ced-8bcd-89bd-b927-cae1bce0365a@web.de>

On Thu, Nov 12, 2020 at 01:20:19PM +0100, René Scharfe wrote:
> Add a helper function for hashing and writing 64-bit integers in network
> byte order.  It returns the number of written bytes.  This simplifies
> callers that keep track of the file offset, even though this number is a
> constant.
>
> Suggested-by: Derrick Stolee <dstolee@microsoft.com>
> Original-patch-by: Taylor Blau <me@ttaylorr.com>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  csum-file.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/csum-file.h b/csum-file.h
> index f9cbd317fb..e54d53d1d0 100644
> --- a/csum-file.h
> +++ b/csum-file.h
> @@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
>  	hashwrite(f, &data, sizeof(data));
>  }
>
> +static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
> +{
> +	data = htonll(data);

Great. This is new from my patch (which wrote the high- and low four
bytes with two separate hashwrite_be32()'s), but I think it's a clear
improvement.

In addition to being more readable, we can use the bswap instruction
once instead of twice if it exists.

Please feel free to add my:

  Signed-off-by: Taylor Blau <me@ttaylorr.com>

Thanks,
Taylor

      parent reply	other threads:[~2020-11-12 14:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 12:20 [PATCH 1/3] csum-file: add hashwrite_be64() René Scharfe
2020-11-12 12:22 ` [PATCH 2/3] midx: use hashwrite_be64() René Scharfe
2020-11-12 12:23 ` [PATCH 3/3] pack-write: " René Scharfe
2020-11-12 13:52 ` [PATCH 1/3] csum-file: add hashwrite_be64() Derrick Stolee
2020-11-12 14:47   ` Taylor Blau
2020-11-12 14:51 ` Taylor Blau [this message]

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=X61L4Ebd5PBpYDel@nand.local \
    --to=me@ttaylorr.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.