diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-11-25 23:24:52 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-25 23:24:52 (GMT) |
commit | 455e8d18f81583d0270685edc6ec2ed201fc984c (patch) | |
tree | cc8a2951eb2473f5970c505d03b1ef5349067d1a | |
parent | 2557c1183a6c6025bc0dd6ebd84354064bb398ec (diff) | |
parent | 970909c2a7803564f82ab1d3660d77ad6a44b68f (diff) | |
download | git-455e8d18f81583d0270685edc6ec2ed201fc984c.zip git-455e8d18f81583d0270685edc6ec2ed201fc984c.tar.gz git-455e8d18f81583d0270685edc6ec2ed201fc984c.tar.bz2 |
Merge branch 'rs/hashwrite-be64'
Code simplification.
* rs/hashwrite-be64:
pack-write: use hashwrite_be64()
midx: use hashwrite_be64()
csum-file: add hashwrite_be64()
-rw-r--r-- | csum-file.h | 7 | ||||
-rw-r--r-- | midx.c | 7 | ||||
-rw-r--r-- | pack-write.c | 5 |
3 files changed, 10 insertions, 9 deletions
diff --git a/csum-file.h b/csum-file.h index f9cbd31..e54d53d 100644 --- a/csum-file.h +++ b/csum-file.h @@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data) hashwrite(f, &data, sizeof(data)); } +static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data) +{ + data = htonll(data); + hashwrite(f, &data, sizeof(data)); + return sizeof(data); +} + #endif @@ -785,9 +785,7 @@ static size_t write_midx_large_offsets(struct hashfile *f, uint32_t nr_large_off if (!(offset >> 31)) continue; - hashwrite_be32(f, offset >> 32); - hashwrite_be32(f, offset & 0xffffffffUL); - written += 2 * sizeof(uint32_t); + written += hashwrite_be64(f, offset); nr_large_offset--; } @@ -975,8 +973,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index * chunk_offsets[i]); hashwrite_be32(f, chunk_ids[i]); - hashwrite_be32(f, chunk_offsets[i] >> 32); - hashwrite_be32(f, chunk_offsets[i]); + hashwrite_be64(f, chunk_offsets[i]); written += MIDX_CHUNKLOOKUP_WIDTH; } diff --git a/pack-write.c b/pack-write.c index 23e19cc..3513665 100644 --- a/pack-write.c +++ b/pack-write.c @@ -151,13 +151,10 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec while (nr_large_offset) { struct pack_idx_entry *obj = *list++; uint64_t offset = obj->offset; - uint32_t split[2]; if (!need_large_offset(offset, opts)) continue; - split[0] = htonl(offset >> 32); - split[1] = htonl(offset & 0xffffffff); - hashwrite(f, split, 8); + hashwrite_be64(f, offset); nr_large_offset--; } } |