Using different hash algorithm in purple_util_get_image_checksum()
Paul Aurich
paul at darkrain42.org
Sat Jul 4 01:33:13 EDT 2009
And Richard Laager spoke on 07/01/2009 10:41 PM, saying:
> On Wed, 2009-07-01 at 01:29 -0700, Mark Doliner wrote:
>> Vijay from Meebo tells me that he seems to
>> remember the sha-1 implementation in glib 2.16 is much faster than the
>> one in our cipher.c.
>
> If this is true and it would be possible, it'd be nice if we just called
> that from our cipher API when libpurple is built against glib >= 2.16.
I've attached a patch that will conditionally use Glib for MD5, SHA1, and
SHA256 when available. `make check` passes with all three and it seems to
work fine.
In a very simplistic benchmark, I loaded the largest image in my
.purple/icons/ (32KiB) and calculated the SHA1sum 100,000 times (and stuck
a g_str_equal() in there just to make sure gcc didn't get cute with me). On
my AMD Athlon 64 4400+, the cipher.c implementation took about 41 seconds
and glib's implementation took about 14 seconds.
Anyone have any problems with my checking this in? The only thing left to
do is deal with the issue in adding data to the checksum, where GChecksum
uses a gssize and we use a gsize for the length, which will be bad when I
decide I want to use Pidgin to calculate the checksum for my 3GB file
(after I dig up a 32-bit system).
~Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glib-checksum.patch
Type: text/x-patch
Size: 12364 bytes
Desc: not available
URL: <http://pidgin.im/pipermail/devel/attachments/20090703/5d12fcee/attachment-0002.bin>
More information about the Devel
mailing list