mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 15:15:44 +00:00
Hashtable: skip rehashing if the size is the same
Hashtable_setSize should not rehash if the actual size stays the same as the number of buckets and natural positions stay the same too.
This commit is contained in:
parent
bc08c7dc2a
commit
d084a80023
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user