Skip to content

Commit 407d914

Browse files
committed
Merge branch 'rs/misc-cleanups'
Code cleanup. * rs/misc-cleanups: pack-write: use hashwrite_be32() in write_idx_file()
2 parents 9f4588d + 389cf68 commit 407d914

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

pack-write.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,8 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
117117
list = sorted_by_sha;
118118
for (i = 0; i < nr_objects; i++) {
119119
struct pack_idx_entry *obj = *list++;
120-
if (index_version < 2) {
121-
uint32_t offset = htonl(obj->offset);
122-
hashwrite(f, &offset, 4);
123-
}
120+
if (index_version < 2)
121+
hashwrite_be32(f, obj->offset);
124122
hashwrite(f, obj->oid.hash, the_hash_algo->rawsz);
125123
if ((opts->flags & WRITE_IDX_STRICT) &&
126124
(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
135133
list = sorted_by_sha;
136134
for (i = 0; i < nr_objects; i++) {
137135
struct pack_idx_entry *obj = *list++;
138-
uint32_t crc32_val = htonl(obj->crc32);
139-
hashwrite(f, &crc32_val, 4);
136+
hashwrite_be32(f, obj->crc32);
140137
}
141138

142139
/* write the 32-bit offset table */
@@ -148,8 +145,7 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
148145
offset = (need_large_offset(obj->offset, opts)
149146
? (0x80000000 | nr_large_offset++)
150147
: obj->offset);
151-
offset = htonl(offset);
152-
hashwrite(f, &offset, 4);
148+
hashwrite_be32(f, offset);
153149
}
154150

155151
/* write the large offset table */

0 commit comments

Comments
 (0)