From a3fbf4dfe1bf2386add261dc7c2809b652b5f9ae Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 16 Apr 2007 12:31:31 -0400 Subject: [PATCH] pack-objects: make in_pack_header_size a variable of its own It currently aliases delta_size on the principle that reused deltas won't go through the whole delta matching loop hence delta_size was unused. This is not true if given delta doesn't find its base in the pack though. But we need that information even for whole object data reuse. Well in short the current state looks awful and is prone to bugs. It just works fine now because try_delta() tests trg_entry->delta before using trg_entry->delta_size, but that is a bit subtle and I was wondering for a while why things just worked fine... even if I'm guilty of having introduced this abomination myself in the first place. Let's do the sensible thing instead with no ambiguity, which is to have a separate variable for in_pack_header_size. This might even help future optimizations. While at it, let's reorder some struct object_entry members so they all align well with their own width, regardless of the architecture or the size of off_t. Some memory saving is to be expected with this alone. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin-pack-objects.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index 7af177667..7100a76cd 100644 --- a/builtin-pack-objects.c +++ b/builtin-pack-objects.c @@ -22,28 +22,26 @@ git-pack-objects [{ -q | --progress | --all-progress }] \n\ struct object_entry { unsigned char sha1[20]; + uint32_t crc32; /* crc of raw pack data for this object */ + off_t offset; /* offset into the final pack file */ unsigned long size; /* uncompressed size */ - off_t offset; /* offset into the final pack file; - * nonzero if already written. - */ - unsigned int depth; /* delta depth */ unsigned int hash; /* name hint hash */ - enum object_type type; - enum object_type in_pack_type; /* could be delta */ - unsigned long delta_size; /* delta data size (uncompressed) */ -#define in_pack_header_size delta_size /* only when reusing pack data */ - struct object_entry *delta; /* delta base object */ + unsigned int depth; /* delta depth */ struct packed_git *in_pack; /* already in pack */ off_t in_pack_offset; + struct object_entry *delta; /* delta base object */ struct object_entry *delta_child; /* deltified objects who bases me */ struct object_entry *delta_sibling; /* other deltified objects who * uses the same base as me */ - int preferred_base; /* we do not pack this, but is encouraged to - * be used as the base objectto delta huge - * objects against. - */ - uint32_t crc32; /* crc of raw pack data for this object */ + unsigned long delta_size; /* delta data size (uncompressed) */ + enum object_type type; + enum object_type in_pack_type; /* could be delta */ + unsigned char in_pack_header_size; + unsigned char preferred_base; /* we do not pack this, but is available + * to be used as the base objectto delta + * objects against. + */ }; /* -- 2.30.2