git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Taylor Blau <me@ttaylorr.com>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH 2/3] midx: use hashwrite_be64()
Date: Thu, 12 Nov 2020 13:22:16 +0100	[thread overview]
Message-ID: <d38ac2a6-261c-4767-8691-8d97d551381c@web.de> (raw)
In-Reply-To: <16932ced-8bcd-89bd-b927-cae1bce0365a@web.de>

Call hashwrite_be64() to write 64-bit values instead of open-coding it
using hashwrite_be32() and sizeof.  This shortens the code and makes its
intent clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
And it saves me from headache induced by trying to remember whether "big
endian" means that the most significant ("big") digit comes first (yes)
or at the end, like the name suggests (no).

 midx.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/midx.c b/midx.c
index d233b54ac7..da03c1449a 100644
--- a/midx.c
+++ b/midx.c
@@ -785,9 +785,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off
 		if (!(offset >> 31))
 			continue;

-		hashwrite_be32(f, offset >> 32);
-		hashwrite_be32(f, offset & 0xffffffffUL);
-		written += 2 * sizeof(uint32_t);
+		written += hashwrite_be64(f, offset);

 		nr_large_offset--;
 	}
@@ -975,8 +973,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 			    chunk_offsets[i]);

 		hashwrite_be32(f, chunk_ids[i]);
-		hashwrite_be32(f, chunk_offsets[i] >> 32);
-		hashwrite_be32(f, chunk_offsets[i]);
+		hashwrite_be64(f, chunk_offsets[i]);

 		written += MIDX_CHUNKLOOKUP_WIDTH;
 	}
--
2.29.2

  reply	other threads:[~2020-11-12 12:22 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 ` René Scharfe [this message]
2020-11-12 12:23 ` [PATCH 3/3] pack-write: use hashwrite_be64() 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

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=d38ac2a6-261c-4767-8691-8d97d551381c@web.de \
    --to=l.s.r@web.de \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.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).