Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
6b9e6714
Commit
6b9e6714
authored
Nov 26, 2012
by
Matthias Braun
Browse files
don't grow the hashset if it just clobbered with deleted entries
parent
b85da3a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/adt/hashset.c.inl
View file @
6b9e6714
...
...
@@ -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);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment