Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Dec 8, 2023
1 parent 8ff29a6 commit 3728c02
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,18 @@ int _dictExpand(dict *d, unsigned long size, int* malloc_failed)

new_ht_used = 0;

/* Prepare a second hash table for incremental rehashing. */
/* Prepare a second hash table for incremental rehashing.
* We do this even for the first initialization, so that we can trigger the
* rehashingStarted more conveniently, we will clean it up right after. */
d->ht_size_exp[1] = new_ht_size_exp;
d->ht_used[1] = new_ht_used;
d->ht_table[1] = new_ht_table;
d->rehashidx = 0;
if (d->type->rehashingStarted) d->type->rehashingStarted(d);

/* Is this the first initialization or is the old ht empty? If so it's not really a rehashing
* we just set the first hash table so that it can accept keys. */
/* Is this the first initialization or is the first hash table empty? If so
* it's not really a rehashing, we can just set the first hash table so that
* it can accept keys. */
if (d->ht_table[0] == NULL || d->ht_used[0] == 0) {
if (d->type->rehashingCompleted) d->type->rehashingCompleted(d);
if (d->ht_used[0] == 0) zfree(d->ht_table[0]);
Expand Down

0 comments on commit 3728c02

Please sign in to comment.