[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] for some of issue #649

From: Greg Stein <gstein_at_lyra.org>
Date: 2003-01-07 04:40:02 CET

On Tue, Jan 07, 2003 at 12:40:55AM +0100, Branko Cibej wrote:
> Karl Fogel wrote:
>
> >+ struct apr_md5_ctx_t context;
> >+ unsigned char digest[MD5_DIGESTSIZE];
> >+
> >+ /* Get a checksum digest for the empty string. */
> >+ apr_md5_init (&context);
> >+ apr_md5_final (digest, &context);
> >
>
> You're doing this in two separate places in the code. Why not just
> calculate that checksum once, and use a statically initialized array?
> It's not as if the MD5 algorithm is about to change.

Right.

>...
> >>> m.digest()
> '\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~'
>
> And there's your array initializer.

For the humans among us who need better readability :-) ...

>>> map(ord, md5.new('').digest())
[212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126]

So you can do:

  static const char empty_digest[] = {
    212, 29, 140, 217, 143, 0, 178, 4, 233, 128, 9, 152, 236, 248, 66, 126
    };

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jan 7 04:39:22 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.