diff options
author | Daniel Lange <DLange@git.local> | 2022-05-02 16:04:22 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2022-05-02 16:04:22 +0200 |
commit | 2f0332b75397ad5240a429d72203f0531011b6a9 (patch) | |
tree | 4782d4b8d0c43f3e6faa1bbbe95816a09e815e67 /Hashtable.c | |
parent | 93c96b12c9cb349b762d38d69568d65cd3e4fbfd (diff) | |
parent | 1b805a31720727008b32b1129a167758519fd4db (diff) | |
download | debian_htop-2f0332b75397ad5240a429d72203f0531011b6a9.tar.gz debian_htop-2f0332b75397ad5240a429d72203f0531011b6a9.tar.bz2 debian_htop-2f0332b75397ad5240a429d72203f0531011b6a9.zip |
Update upstream source from tag 'upstream/3.2.0'
Update to upstream version '3.2.0'
with Debian dir 5ce130e9471b77941bbd217b5ea8b7b3419a91c6
Diffstat (limited to 'Hashtable.c')
-rw-r--r-- | Hashtable.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Hashtable.c b/Hashtable.c index c880cf7..a0cfc9e 100644 --- a/Hashtable.c +++ b/Hashtable.c @@ -90,7 +90,7 @@ size_t Hashtable_count(const Hashtable* this) { /* https://oeis.org/A014234 */ static const uint64_t OEISprimes[] = { - 2, 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, 134217689, 268435399, 536870909, 1073741789, @@ -191,10 +191,14 @@ void Hashtable_setSize(Hashtable* this, size_t size) { if (size <= this->items) return; + size_t newSize = nextPrime(size); + if (newSize == this->size) + return; + HashtableItem* oldBuckets = this->buckets; size_t oldSize = this->size; - this->size = nextPrime(size); + this->size = newSize; this->buckets = (HashtableItem*) xCalloc(this->size, sizeof(HashtableItem)); this->items = 0; @@ -282,7 +286,7 @@ void* Hashtable_remove(Hashtable* this, ht_key_t key) { /* shrink on load-factor < 0.125 */ if (8 * this->items < this->size) - Hashtable_setSize(this, this->size / 2); + Hashtable_setSize(this, this->size / 3); /* account for nextPrime rounding up */ return res; } |