hash: avoid no-op rehashing
authorEric Blake <ebb9@byu.net>
Thu, 18 Jun 2009 19:18:34 +0000 (13:18 -0600)
committerEric Blake <ebb9@byu.net>
Thu, 18 Jun 2009 19:18:34 +0000 (13:18 -0600)
* lib/hash.c (hash_rehash): Recognize useless rehash attempts.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/hash.c

index 6861f6b..e7698b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-06-18  Eric Blake  <ebb9@byu.net>
 
+       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.
index 59f1ff0..f2123b4 100644 (file)
@@ -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