{"thread":{"id":"5949","subject":"[PATCH] reduce delta head inflated size","startedAt":"2006-10-18T19:56:22Z","lastAt":"2006-10-19T14:17:21Z","messageCount":3,"participants":["Nicolas Pitre","Morten Welinder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"29142","messageId":"Pine.LNX.4.64.0610181541280.1971@xanadu.home","threadId":"5949","inReplyTo":null,"subject":"[PATCH] reduce delta head inflated size","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-10-18T19:56:22Z","receivedAt":"2006-10-18T19:56:22Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Supposing that both the base and result sizes were both full size 64-bit \nvalues, their encoding would occupy only 9.2 bytes each.  Therefore \ninflating 64 bytes is way overkill.  Limit it to 20 bytes instead which \nshould be plenty enough for a couple years to come.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 25c0bf9..e89d24c 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -943,7 +943,7 @@ static int packed_delta_info(struct pack\n \n \tif (sizep) {\n \t\tconst unsigned char *data;\n-\t\tunsigned char delta_head[64];\n+\t\tunsigned char delta_head[20];\n \t\tunsigned long result_size;\n \t\tz_stream stream;\n \t\tint st;\n"},{"id":"29231","messageId":"118833cc0610190649o484afdc8lb871d4b3c5361166@mail.gmail.com","threadId":"5949","inReplyTo":"Pine.LNX.4.64.0610181541280.1971@xanadu.home","subject":"Re: [PATCH] reduce delta head inflated size","fromName":"Morten Welinder","fromEmail":"mwelinder@gmail.com","sentAt":"2006-10-19T13:49:01Z","receivedAt":"2006-10-19T13:49:01Z","isPatch":true,"sender":{"key":"mwelinder@gmail.com","avatar":null},"body":"On 10/18/06, Nicolas Pitre <nico@cam.org> wrote:\n> Supposing that both the base and result sizes were both full size 64-bit\n> values, their encoding would occupy only 9.2 bytes each.  Therefore\n> inflating 64 bytes is way overkill.  Limit it to 20 bytes instead which\n> should be plenty enough for a couple years to come.\n\n2^63 ~ 9.2e18\n\nThus one signed 64-bit number can take up 1 sign + 19 digits + 1 nul.\nThat's 21 bytes.\n\nIf you don't like the constant, 4*sizeof(integer type) should work.\n(Assuming sizeof measures in bytes.)\n\nM.\n"},{"id":"29234","messageId":"Pine.LNX.4.64.0610191012090.1971@xanadu.home","threadId":"5949","inReplyTo":"118833cc0610190649o484afdc8lb871d4b3c5361166@mail.gmail.com","subject":"Re: [PATCH] reduce delta head inflated size","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-10-19T14:17:21Z","receivedAt":"2006-10-19T14:17:21Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Thu, 19 Oct 2006, Morten Welinder wrote:\n\n> On 10/18/06, Nicolas Pitre <nico@cam.org> wrote:\n> > Supposing that both the base and result sizes were both full size 64-bit\n> > values, their encoding would occupy only 9.2 bytes each.  Therefore\n> > inflating 64 bytes is way overkill.  Limit it to 20 bytes instead which\n> > should be plenty enough for a couple years to come.\n> \n> 2^63 ~ 9.2e18\n> \n> Thus one signed 64-bit number can take up 1 sign + 19 digits + 1 nul.\n> That's 21 bytes.\n\nNo.  In this case the value is kept binary, with bits spread over \nconsecutive bytes but with the MSB indicating continuation on the next \nbyte.\n\nThis means 64 bits / 7 bits per byte = 9.1 bytes, hence 10.  Then there \nare 2 of those values that makes 20 bytes.\n\n\nNicolas\n"}]}