summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-11-01 08:52:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-01 23:52:51 (GMT)
commit06d43fad18a2bb85b1a224b07c4cc572c7e41f7e (patch)
tree660ced64b50908f3e501275d96129523978fa4ce /pack-write.c
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
downloadgit-06d43fad18a2bb85b1a224b07c4cc572c7e41f7e.zip
git-06d43fad18a2bb85b1a224b07c4cc572c7e41f7e.tar.gz
git-06d43fad18a2bb85b1a224b07c4cc572c7e41f7e.tar.bz2
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>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/pack-write.c b/pack-write.c
index a6cdb3c..23e19cc 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -48,7 +48,6 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
struct hashfile *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;
off_t last_obj_offset = 0;
- uint32_t array[256];
int i, fd;
uint32_t index_version;
@@ -106,10 +105,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
break;
next++;
}
- array[i] = htonl(next - sorted_by_sha);
+ hashwrite_be32(f, next - sorted_by_sha);
list = next;
}
- hashwrite(f, array, 256 * 4);
/*
* Write the actual SHA1 entries..