{"thread":{"id":"54197","subject":"[PATCH] midx: use hashwrite_u8() in write_midx_header()","startedAt":"2020-09-06T08:59:17Z","lastAt":"2020-09-06T19:03:49Z","messageCount":2,"participants":["René Scharfe","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"405088","messageId":"ae03833d-d597-f902-38d5-9e67bd768d93@web.de","threadId":"54197","inReplyTo":null,"subject":"[PATCH] midx: use hashwrite_u8() in write_midx_header()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2020-09-06T08:59:02Z","receivedAt":"2020-09-06T08:59:17Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Emit byte-sized values using hashwrite_u8() instead of buffering them\nlocally first.  The hashwrite functions already do their own buffering,\nso this double-buffering does not reduce the number of system calls.\nGetting rid of it shortens and simplifies the code a bit.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n midx.c | 11 ++++-------\n 1 file changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/midx.c b/midx.c\nindex e9b2e1253a..6326ae17c6 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -428,14 +428,11 @@ static size_t write_midx_header(struct hashfile *f,\n \t\t\t\tunsigned char num_chunks,\n \t\t\t\tuint32_t num_packs)\n {\n-\tunsigned char byte_values[4];\n-\n \thashwrite_be32(f, MIDX_SIGNATURE);\n-\tbyte_values[0] = MIDX_VERSION;\n-\tbyte_values[1] = oid_version();\n-\tbyte_values[2] = num_chunks;\n-\tbyte_values[3] = 0; /* unused */\n-\thashwrite(f, byte_values, sizeof(byte_values));\n+\thashwrite_u8(f, MIDX_VERSION);\n+\thashwrite_u8(f, oid_version());\n+\thashwrite_u8(f, num_chunks);\n+\thashwrite_u8(f, 0); /* unused */\n \thashwrite_be32(f, num_packs);\n\n \treturn MIDX_HEADER_SIZE;\n--\n2.28.0\n"},{"id":"405094","messageId":"20200906190340.GB6146@nand.local","threadId":"54197","inReplyTo":"ae03833d-d597-f902-38d5-9e67bd768d93@web.de","subject":"Re: [PATCH] midx: use hashwrite_u8() in write_midx_header()","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2020-09-06T19:03:40Z","receivedAt":"2020-09-06T19:03:49Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Sun, Sep 06, 2020 at 10:59:02AM +0200, René Scharfe wrote:\n> Emit byte-sized values using hashwrite_u8() instead of buffering them\n> locally first.  The hashwrite functions already do their own buffering,\n> so this double-buffering does not reduce the number of system calls.\n> Getting rid of it shortens and simplifies the code a bit.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n\nLooks great.\n\n  Acked-by: Taylor Blau <me@ttaylorr.com>\n\nThanks,\nTaylor\n"}]}