pack-write: use hashwrite_be64()
Call hashwrite_be64() to write a 64-bit value instead of open-coding it using htonl() and hashwrite(). This shortens the code, gets rid of a buffer and several magic numbers, and makes the intent clearer. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Nov 12, 2020 at 13:23 UTC
970909c2a7803564f82ab1d3660d77ad6a44b68f
1 file changed
+1
-4
pack-write.c
+1
-4
@@ -153,13 +153,10 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
153
while (nr_large_offset) {
154
struct pack_idx_entry *obj = *list++;
155
uint64_t offset = obj->offset;
156
- uint32_t split[2];
156
157
if (!need_large_offset(offset, opts))
158
continue;
160
- split[0] = htonl(offset >> 32);
161
- split[1] = htonl(offset & 0xffffffff);
162
- hashwrite(f, split, 8);
159
+ hashwrite_be64(f, offset);
160
nr_large_offset--;
161
}
162
}