@matheusbsbs / matheus-bagliano / commits / 014f1447f0
Fork 0

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>

René Scharfe committed Sep 6, 2020 at 10:59 UTC 014f1447f0382b323b53006a65dd2b8383427dc8
1 file changed +4 -7
midx.c
+4 -7
@@ -428,14 +428,11 @@ static size_t write_midx_header(struct hashfile *f,
428 unsigned char num_chunks,
429 uint32_t num_packs)
430 {
431 - unsigned char byte_values[4];
432 -
431 hashwrite_be32(f, MIDX_SIGNATURE);
434 - byte_values[0] = MIDX_VERSION;
435 - byte_values[1] = oid_version();
436 - byte_values[2] = num_chunks;
437 - byte_values[3] = 0; /* unused */
438 - hashwrite(f, byte_values, sizeof(byte_values));
432 + hashwrite_u8(f, MIDX_VERSION);
433 + hashwrite_u8(f, oid_version());
434 + hashwrite_u8(f, num_chunks);
435 + hashwrite_u8(f, 0); /* unused */
436 hashwrite_be32(f, num_packs);
437
438 return MIDX_HEADER_SIZE;