Skip to content

Commit 014f144

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ccb181d commit 014f144

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

midx.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,11 @@ static size_t write_midx_header(struct hashfile *f,
428428
unsigned char num_chunks,
429429
uint32_t num_packs)
430430
{
431-
unsigned char byte_values[4];
432-
433431
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 */
439436
hashwrite_be32(f, num_packs);
440437

441438
return MIDX_HEADER_SIZE;

0 commit comments

Comments
 (0)