{"thread":{"id":"20648","subject":"[PATCH] block-sha1: make the size member first in the context struct","startedAt":"2009-08-18T00:18:23Z","lastAt":"2009-08-18T00:39:30Z","messageCount":3,"participants":["Nicolas Pitre","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"121032","messageId":"alpine.LFD.2.00.0908172012591.6044@xanadu.home","threadId":"20648","inReplyTo":null,"subject":"[PATCH] block-sha1: make the size member first in the context struct","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-18T00:18:23Z","receivedAt":"2009-08-18T00:18:23Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"This is a 64-bit value, hence having it first provides a better \nalignment.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\ndiff --git a/block-sha1/sha1.h b/block-sha1/sha1.h\nindex 6ff59b2..b864df6 100644\n--- a/block-sha1/sha1.h\n+++ b/block-sha1/sha1.h\n@@ -7,9 +7,9 @@\n  */\n \n typedef struct {\n+\tunsigned long long size;\n \tunsigned int H[5];\n \tunsigned int W[16];\n-\tunsigned long long size;\n } blk_SHA_CTX;\n \n void blk_SHA1_Init(blk_SHA_CTX *ctx);\n"},{"id":"121033","messageId":"alpine.DEB.1.00.0908180223280.8306@pacific.mpi-cbg.de","threadId":"20648","inReplyTo":"alpine.LFD.2.00.0908172012591.6044@xanadu.home","subject":"Re: [PATCH] block-sha1: make the size member first in the context struct","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-18T00:24:02Z","receivedAt":"2009-08-18T00:24:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 17 Aug 2009, Nicolas Pitre wrote:\n\n> This is a 64-bit value, hence having it first provides a better \n> alignment.\n> \n> Signed-off-by: Nicolas Pitre <nico@cam.org>\n> \n> diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h\n> index 6ff59b2..b864df6 100644\n> --- a/block-sha1/sha1.h\n> +++ b/block-sha1/sha1.h\n> @@ -7,9 +7,9 @@\n>   */\n>  \n>  typedef struct {\n> +\tunsigned long long size;\n>  \tunsigned int H[5];\n>  \tunsigned int W[16];\n> -\tunsigned long long size;\n>  } blk_SHA_CTX;\n\nBy the reasoning suggested in the commit message, should H[5] not go to \nthe end?\n\nCiao,\nDscho\n"},{"id":"121036","messageId":"alpine.LFD.2.00.0908172035320.6044@xanadu.home","threadId":"20648","inReplyTo":"alpine.DEB.1.00.0908180223280.8306@pacific.mpi-cbg.de","subject":"Re: [PATCH] block-sha1: make the size member first in the context struct","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-18T00:39:30Z","receivedAt":"2009-08-18T00:39:30Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 18 Aug 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Mon, 17 Aug 2009, Nicolas Pitre wrote:\n> \n> > This is a 64-bit value, hence having it first provides a better \n> > alignment.\n> > \n> > Signed-off-by: Nicolas Pitre <nico@cam.org>\n> > \n> > diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h\n> > index 6ff59b2..b864df6 100644\n> > --- a/block-sha1/sha1.h\n> > +++ b/block-sha1/sha1.h\n> > @@ -7,9 +7,9 @@\n> >   */\n> >  \n> >  typedef struct {\n> > +\tunsigned long long size;\n> >  \tunsigned int H[5];\n> >  \tunsigned int W[16];\n> > -\tunsigned long long size;\n> >  } blk_SHA_CTX;\n> \n> By the reasoning suggested in the commit message, should H[5] not go to \n> the end?\n\nBoth arrays are based of unsigned ints which have the same alignment \nrules.  Furthermore the size and H members are much more used than the W \nmember, and keeping them close should help with CPU cache locality.\n\n\nNicolas\n"}]}