From 86514ea5ebf71c35726c21ae077f2a3a10e196e2 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 18 Jun 2009 13:18:34 -0600 Subject: [PATCH] hash: avoid no-op rehashing * lib/hash.c (hash_rehash): Recognize useless rehash attempts. Signed-off-by: Eric Blake --- ChangeLog | 3 +++ lib/hash.c | 2 ++ 2 files changed, 5 insertions(+) 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 -- 2.11.0