mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
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 <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
81a216a5d6
commit
a3fbf4dfe1
|
@ -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.
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue