bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another sha1/md[45] refinement


From: Jim Meyering
Subject: Re: Yet another sha1/md[45] refinement
Date: Fri, 01 Feb 2008 08:35:55 +0100

Bruno Haible <address@hidden> wrote:

> Jim Meyering wrote:
>> +  set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
>> +  set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
>> +  set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
>> +  set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
>
> Now this is confusing.

Now, now.  Don't overstate the case.
I'm sure you were not confused.

> If you assume that A, B, C, D all have the same
> size, then it's simpler (more symmetry) to write:

I see as much simplicity/symmetry either way.
row-based above, column-based below.
I did consider what you propose, but still
have a slight bias for the approach I chose.

>      set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
>      set_uint32 (r + 1 * sizeof ctx->A, SWAP (ctx->B));
>      set_uint32 (r + 2 * sizeof ctx->A, SWAP (ctx->C));
>      set_uint32 (r + 3 * sizeof ctx->A, SWAP (ctx->D));

The only way that code can be useful is when A, B, C, and D
all have the same size, so I chose row-based symmetry.

> If you don't want to assume this, then the code above is incorrect (it

Good debate technique :-)
"If <outrageous condition>, then *UGLY CODE*"

> stores the second element at offset sizeof(B) but should store it at the
> offset sizeof(A), etc.) and should be corrected like this:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]