{"thread":{"id":"7695","subject":"[PATCH 7/9] pack-objects: make in_pack_header_size a variable of its own","startedAt":"2007-04-16T16:31:31Z","lastAt":"2007-04-16T16:31:31Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"39550","messageId":"alpine.LFD.0.98.0704161231080.4504@xanadu.home","threadId":"7695","inReplyTo":null,"subject":"[PATCH 7/9] pack-objects: make in_pack_header_size a variable of its own","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-04-16T16:31:31Z","receivedAt":"2007-04-16T16:31:31Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"It currently aliases delta_size on the principle that reused deltas won't\ngo through the whole delta matching loop hence delta_size was unused.\nThis is not true if given delta doesn't find its base in the pack though.\nBut we need that information even for whole object data reuse.\n\nWell in short the current state looks awful and is prone to bugs.  It just\nworks fine now because try_delta() tests trg_entry->delta before using\ntrg_entry->delta_size, but that is a bit subtle and I was wondering for a\nwhile why things just worked fine... even if I'm guilty of having\nintroduced this abomination myself in the first place.\n\nLet's do the sensible thing instead with no ambiguity, which is to have\na separate variable for in_pack_header_size.  This might even help future\noptimizations.\n\nWhile at it, let's reorder some struct object_entry members so they all\nalign well with their own width, regardless of the architecture or the\nsize of off_t.  Some memory saving is to be expected with this alone.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n builtin-pack-objects.c |   26 ++++++++++++--------------\n 1 files changed, 12 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 7af1776..7100a76 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -22,28 +22,26 @@ git-pack-objects [{ -q | --progress | --all-progress }] \\n\\\n \n struct object_entry {\n \tunsigned char sha1[20];\n+\tuint32_t crc32;\t\t/* crc of raw pack data for this object */\n+\toff_t offset;\t\t/* offset into the final pack file */\n \tunsigned long size;\t/* uncompressed size */\n-\toff_t offset;\t/* offset into the final pack file;\n-\t\t\t\t * nonzero if already written.\n-\t\t\t\t */\n-\tunsigned int depth;\t/* delta depth */\n \tunsigned int hash;\t/* name hint hash */\n-\tenum object_type type;\n-\tenum object_type in_pack_type;\t/* could be delta */\n-\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n-#define in_pack_header_size delta_size\t/* only when reusing pack data */\n-\tstruct object_entry *delta;\t/* delta base object */\n+\tunsigned int depth;\t/* delta depth */\n \tstruct packed_git *in_pack; \t/* already in pack */\n \toff_t in_pack_offset;\n+\tstruct object_entry *delta;\t/* delta base object */\n \tstruct object_entry *delta_child; /* deltified objects who bases me */\n \tstruct object_entry *delta_sibling; /* other deltified objects who\n \t\t\t\t\t     * uses the same base as me\n \t\t\t\t\t     */\n-\tint preferred_base;\t/* we do not pack this, but is encouraged to\n-\t\t\t\t * be used as the base objectto delta huge\n-\t\t\t\t * objects against.\n-\t\t\t\t */\n-\tuint32_t crc32;\t\t/* crc of raw pack data for this object */\n+\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n+\tenum object_type type;\n+\tenum object_type in_pack_type;\t/* could be delta */\n+\tunsigned char in_pack_header_size;\n+\tunsigned char preferred_base; /* we do not pack this, but is available\n+\t\t\t\t       * to be used as the base objectto delta\n+\t\t\t\t       * objects against.\n+\t\t\t\t       */\n };\n \n /*\n-- \n1.5.1.1.781.g65e8\n"}]}