pack-write: use hashwrite_be32() instead of double-buffering array

hashwrite() already buffers writes, so pass the fanout table entries individually via hashwrite_be32(), which also does the endianess conversion for us. This avoids a memory copy, shortens the code and reduces the number of magic numbers. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 1, 2020 at 09:52 UTC 06d43fad18a2bb85b1a224b07c4cc572c7e41f7e
1 file changed +1 -3
pack-write.c
+1 -3
@@ -48,7 +48,6 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
48 struct hashfile *f;
49 struct pack_idx_entry **sorted_by_sha, **list, **last;
50 off_t last_obj_offset = 0;
51 - uint32_t array[256];
51 int i, fd;
52 uint32_t index_version;
53
@@ -106,10 +105,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
105 break;
106 next++;
107 }
109 - array[i] = htonl(next - sorted_by_sha);
108 + hashwrite_be32(f, next - sorted_by_sha);
109 list = next;
110 }
112 - hashwrite(f, array, 256 * 4);
111
112 /*
113 * Write the actual SHA1 entries..