From: Eric Blake Date: Thu, 18 Jun 2009 19:18:34 +0000 (-0600) Subject: hash: avoid no-op rehashing X-Git-Tag: v0.1~5849 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=86514ea5ebf71c35726c21ae077f2a3a10e196e2;p=gnulib.git hash: avoid no-op rehashing * lib/hash.c (hash_rehash): Recognize useless rehash attempts. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 6861f6b19..e7698b70c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-06-18 Eric Blake + hash: avoid no-op rehashing + * lib/hash.c (hash_rehash): Recognize useless rehash attempts. + hash: provide default callback functions * lib/hash.c (raw_hasher, raw_comparator): New functions. (hash_initialize): Use them as defaults. diff --git a/lib/hash.c b/lib/hash.c index 59f1ff0d0..f2123b4e4 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -862,6 +862,8 @@ hash_rehash (Hash_table *table, size_t candidate) table->comparator, table->data_freer); if (new_table == NULL) return false; + if (new_table->n_buckets == table->n_buckets) + return true; /* Merely reuse the extra old space into the new table. */ #if USE_OBSTACK