bug-gnulib
[Top][All Lists]
Advanced

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

Re: another hash cleanup


From: Eric Blake
Subject: Re: another hash cleanup
Date: Fri, 19 Jun 2009 05:58:29 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Jim Meyering on 6/19/2009 1:19 AM:
> However, I have a slight preference for this, since it leaves us
> with less duplication of implementation-specific details:
> 
>   if (new_table->n_buckets == table->n_buckets)
>     {
>       hash_free (new_table);
>       return true;
>     }
> 
> It's on a cold code path, so the small amount of extra work isn't an issue.
> Also, by using hash_free, we avoid a leak in the USE_OBSTACK code.
> 

Good catch (although the bit about USE_OBSTACK may be obsolete if I can
get my alternate overflow management patch rebased on to the current state
of the tree).

But, come to think of it, why are we even malloc'ing the new_table at all
in this code path?  Maybe the better technical approach would be factoring
out the table size computation from hash_initialize, and have both
hash_initialize and hash_rehash first compute the needed size and later do
the malloc, so that hash_rehash doesn't even malloc in the first place if
the size computation shows it isn't necessary.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAko7fWUACgkQ84KuGfSFAYD0cwCgk5LnhwWywlq05SfNPZiWaEXa
rVcAoMMGA0h+eWyH9Kl6H1GgvFPDrfOl
=shNe
-----END PGP SIGNATURE-----




reply via email to

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