Skip to content

Commit 06d43fa

Browse files
rscharfegitster
authored andcommitted
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>
1 parent 898f807 commit 06d43fa

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pack-write.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
4848
struct hashfile *f;
4949
struct pack_idx_entry **sorted_by_sha, **list, **last;
5050
off_t last_obj_offset = 0;
51-
uint32_t array[256];
5251
int i, fd;
5352
uint32_t index_version;
5453

@@ -106,10 +105,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
106105
break;
107106
next++;
108107
}
109-
array[i] = htonl(next - sorted_by_sha);
108+
hashwrite_be32(f, next - sorted_by_sha);
110109
list = next;
111110
}
112-
hashwrite(f, array, 256 * 4);
113111

114112
/*
115113
* Write the actual SHA1 entries..

0 commit comments

Comments
 (0)