X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fadt%2Fhashset.c.inl;h=06f4312cd00fd83d217f2ad31b629567775eb81c;hb=b59e22a229aa1227ef992c184c79fdafe34908cf;hp=e0cf70c77a091d9f9e44369cb777abbd066fec27;hpb=8597cc9fea0f7ce133b4fe817dc8c6493b6ef41a;p=libfirm diff --git a/ir/adt/hashset.c.inl b/ir/adt/hashset.c.inl index e0cf70c77..06f4312cd 100644 --- a/ir/adt/hashset.c.inl +++ b/ir/adt/hashset.c.inl @@ -44,7 +44,7 @@ * Defining this implies, that a data value contains * more than just the key. *
  • GetKey(value) Extracts the key from a data value
  • - *
  • KeysEqual(hashset,key1,key2) Tests wether 2 keys are equal
  • + *
  • KeysEqual(hashset,key1,key2) Tests whether 2 keys are equal
  • *
  • DO_REHASH Instead of storing the hash-values, recalculate * them on demand from the datavalues. (useful if * calculating the hash-values takes less time than @@ -346,13 +346,20 @@ static inline void resize(HashSet *self, size_t new_size); */ static inline void maybe_grow(HashSet *self) { - size_t resize_to; - if (LIKELY(self->num_elements + 1 <= self->enlarge_threshold)) return; - /* double table size */ - resize_to = self->num_buckets * 2; + size_t resize_to; + if (self->num_elements - self->num_deleted + 2 > self->enlarge_threshold) { + /* double table size */ + resize_to = self->num_buckets * 2; + if (resize_to <= self->num_buckets) { + abort(); + } + } else { + /* no need to resize, we just clean up the deleted entries */ + resize_to = self->num_buckets; + } resize(self, resize_to); }