From 629dffc461f3631bb7acfe905d805caa38b49dfa Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 25 May 2020 19:59:10 +0000 Subject: packfile: compute and use the index CRC offset Both v2 pack index files and the v3 format specified as part of the NewHash work have similar data starting at the CRC table. Much of the existing code wants to read either this table or the offset entries following it, and in doing so computes the offset each time. In order to share as much code between v2 and v3, compute the offset of the CRC table and store it when the pack is opened. Use this value to compute offsets to not only the CRC table, but to the offset entries beyond it. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- packfile.c | 1 + 1 file changed, 1 insertion(+) (limited to 'packfile.c') diff --git a/packfile.c b/packfile.c index f4e752996d..6ab5233613 100644 --- a/packfile.c +++ b/packfile.c @@ -178,6 +178,7 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map, */ (sizeof(off_t) <= 4)) return error("pack too large for current definition of off_t in %s", path); + p->crc_offset = 8 + 4 * 256 + nr * hashsz; } p->index_version = version; -- cgit v1.3