summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-06 08:59:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-06 20:40:40 (GMT)
commit014f1447f0382b323b53006a65dd2b8383427dc8 (patch)
tree92e26500711e5bbeb318da172742a5cb08d5cb89 /midx.c
parentccb181d0f053100a988ee0a240e3c0c0bb962d4d (diff)
downloadgit-014f1447f0382b323b53006a65dd2b8383427dc8.zip
git-014f1447f0382b323b53006a65dd2b8383427dc8.tar.gz
git-014f1447f0382b323b53006a65dd2b8383427dc8.tar.bz2
midx: use hashwrite_u8() in write_midx_header()
Emit byte-sized values using hashwrite_u8() instead of buffering them locally first. The hashwrite functions already do their own buffering, so this double-buffering does not reduce the number of system calls. Getting rid of it shortens and simplifies the code a bit. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/midx.c b/midx.c
index e9b2e12..6326ae1 100644
--- a/midx.c
+++ b/midx.c
@@ -428,14 +428,11 @@ static size_t write_midx_header(struct hashfile *f,
unsigned char num_chunks,
uint32_t num_packs)
{
- unsigned char byte_values[4];
-
hashwrite_be32(f, MIDX_SIGNATURE);
- byte_values[0] = MIDX_VERSION;
- byte_values[1] = oid_version();
- byte_values[2] = num_chunks;
- byte_values[3] = 0; /* unused */
- hashwrite(f, byte_values, sizeof(byte_values));
+ hashwrite_u8(f, MIDX_VERSION);
+ hashwrite_u8(f, oid_version());
+ hashwrite_u8(f, num_chunks);
+ hashwrite_u8(f, 0); /* unused */
hashwrite_be32(f, num_packs);
return MIDX_HEADER_SIZE;