X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fhtable%2Fhtable.c;h=bbd4fa96e587c64a04446756787bd163ad4dc3c8;hp=dec53127470a9f6b06a53555286a9fcbb153dbef;hb=d3104024f71cf4f89195787add6c7ac381d62f40;hpb=78e983a7a6e5250ebf963d5d93fe34c1d27d5a39 diff --git a/ccan/htable/htable.c b/ccan/htable/htable.c index dec53127..bbd4fa96 100644 --- a/ccan/htable/htable.c +++ b/ccan/htable/htable.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -170,7 +171,16 @@ static COLD_ATTRIBUTE bool double_table(struct htable *ht) ht->max *= 2; ht->max_with_deleted *= 2; - /* FIXME: If we lost our perfect bit, we could reclaim it here! */ + /* If we lost our "perfect bit", get it back now. */ + if (!ht->perfect_bit && ht->common_mask) { + for (i = 0; i < sizeof(ht->common_mask) * CHAR_BIT; i++) { + if (ht->common_mask & ((size_t)1 << i)) { + ht->perfect_bit = (size_t)1 << i; + break; + } + } + } + for (i = 0; i < oldnum; i++) { if (entry_is_valid(e = oldtable[i])) { void *p = get_raw_ptr(ht, e);