changeset 11638:bddc78d1a1c2

hash: avoid no-op rehashing * lib/hash.c (hash_rehash): Recognize useless rehash attempts. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Thu, 18 Jun 2009 13:18:34 -0600
parents 0b026e877c96
children b2e769838448
files ChangeLog lib/hash.c
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -862,6 +862,8 @@
 			       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