git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] midx: use hashwrite_u8() in write_midx_header()

From
René Scharfe <l.s.r@web.de>
Date
Sep 6, 2020, 08:59 UTC
Message-ID
<ae03833d-d597-f902-38d5-9e67bd768d93@web.de>

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>
---
 midx.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/midx.c b/midx.c
index e9b2e1253a..6326ae17c6 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;
--
2.28.0
Next: Taylor Blau
Message 1 of 2 in “midx: use hashwrite_u8() in write_midx_header()”
  1. midx: use hashwrite_u8() in write_midx_header()René Scharfe, Sep 6, 2020
  2. Taylor BlauSep 6, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.