summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-19 18:26:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-19 19:15:36 (GMT)
commit389cf68caf8bc79669133c8744b06092925461e0 (patch)
tree8540e4b16e233da5d7bd89f2311adc346a50369e /pack-write.c
parent7744a5d6921c457a05224cd7f5554e972df634b0 (diff)
downloadgit-389cf68caf8bc79669133c8744b06092925461e0.zip
git-389cf68caf8bc79669133c8744b06092925461e0.tar.gz
git-389cf68caf8bc79669133c8744b06092925461e0.tar.bz2
pack-write: use hashwrite_be32() in write_idx_file()
Call hashwrite_be32() instead of open-coding it. This shortens the code a bit and makes it easier to read. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/pack-write.c b/pack-write.c
index 685d327..a6cdb3c 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -117,10 +117,8 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
list = sorted_by_sha;
for (i = 0; i < nr_objects; i++) {
struct pack_idx_entry *obj = *list++;
- if (index_version < 2) {
- uint32_t offset = htonl(obj->offset);
- hashwrite(f, &offset, 4);
- }
+ if (index_version < 2)
+ hashwrite_be32(f, obj->offset);
hashwrite(f, obj->oid.hash, the_hash_algo->rawsz);
if ((opts->flags & WRITE_IDX_STRICT) &&
(i && oideq(&list[-2]->oid, &obj->oid)))
@@ -135,8 +133,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
list = sorted_by_sha;
for (i = 0; i < nr_objects; i++) {
struct pack_idx_entry *obj = *list++;
- uint32_t crc32_val = htonl(obj->crc32);
- hashwrite(f, &crc32_val, 4);
+ hashwrite_be32(f, obj->crc32);
}
/* write the 32-bit offset table */
@@ -148,8 +145,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
offset = (need_large_offset(obj->offset, opts)
? (0x80000000 | nr_large_offset++)
: obj->offset);
- offset = htonl(offset);
- hashwrite(f, &offset, 4);
+ hashwrite_be32(f, offset);
}
/* write the large offset table */