htable: use "perfect" bit to reduce rehashes.
[ccan] / ccan / htable / tools / speed.c
index d5a3f6520fb2267f61c4a80c2faef27604a8ef5d..72a08e6b4cd1e253b14436e644d5ab5d5608739f 100644 (file)
@@ -73,8 +73,11 @@ static size_t perfect(const struct htable *ht)
                if (!entry_is_valid(ht->table[i]))
                        continue;
                if (hash_bucket(ht, ht->rehash(get_raw_ptr(ht, ht->table[i]),
-                                              ht->priv)) == i)
+                                              ht->priv)) == i) {
+                       assert((ht->table[i] & ht->perfect_bit)
+                              == ht->perfect_bit);
                        placed_perfect++;
+               }
        }
        return placed_perfect;
 }