Skip to content

Commit

Permalink
st.c: spell `perturb' properly
Browse files Browse the repository at this point in the history
Otherwise, a reader may wonder who `Peter B.' is and why
a variable is named after them...
  • Loading branch information
Eric Wong committed Feb 10, 2023
1 parent 94aed6e commit b9f90ca
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions st.c
Expand Up @@ -768,7 +768,7 @@ rebuild_table(st_table *tab)
}

/* Return the next secondary hash index for table TAB using previous
index IND and PERTERB. Finally modulo of the function becomes a
index IND and PERTURB. Finally modulo of the function becomes a
full *cycle linear congruential generator*, in other words it
guarantees traversing all table bins in extreme case.
Expand All @@ -780,10 +780,10 @@ rebuild_table(st_table *tab)
For our case a is 5, c is 1, and m is a power of two. */
static inline st_index_t
secondary_hash(st_index_t ind, st_table *tab, st_index_t *perterb)
secondary_hash(st_index_t ind, st_table *tab, st_index_t *perturb)
{
*perterb >>= 11;
ind = (ind << 2) + ind + *perterb + 1;
*perturb >>= 11;
ind = (ind << 2) + ind + *perturb + 1;
return hash_bin(ind, tab);
}

Expand Down Expand Up @@ -826,7 +826,7 @@ find_table_entry_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
#ifdef QUADRATIC_PROBE
st_index_t d;
#else
st_index_t peterb;
st_index_t perturb;
#endif
st_index_t bin;
st_table_entry *entries = tab->entries;
Expand All @@ -835,7 +835,7 @@ find_table_entry_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
#ifdef QUADRATIC_PROBE
d = 1;
#else
peterb = hash_value;
perturb = hash_value;
#endif
FOUND_BIN;
for (;;) {
Expand All @@ -853,7 +853,7 @@ find_table_entry_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
ind = hash_bin(ind + d, tab);
d++;
#else
ind = secondary_hash(ind, tab, &peterb);
ind = secondary_hash(ind, tab, &perturb);
#endif
COLLISION;
}
Expand All @@ -872,7 +872,7 @@ find_table_bin_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
#ifdef QUADRATIC_PROBE
st_index_t d;
#else
st_index_t peterb;
st_index_t perturb;
#endif
st_index_t bin;
st_table_entry *entries = tab->entries;
Expand All @@ -881,7 +881,7 @@ find_table_bin_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
#ifdef QUADRATIC_PROBE
d = 1;
#else
peterb = hash_value;
perturb = hash_value;
#endif
FOUND_BIN;
for (;;) {
Expand All @@ -899,7 +899,7 @@ find_table_bin_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
ind = hash_bin(ind + d, tab);
d++;
#else
ind = secondary_hash(ind, tab, &peterb);
ind = secondary_hash(ind, tab, &perturb);
#endif
COLLISION;
}
Expand All @@ -916,15 +916,15 @@ find_table_bin_ind_direct(st_table *tab, st_hash_t hash_value, st_data_t key)
#ifdef QUADRATIC_PROBE
st_index_t d;
#else
st_index_t peterb;
st_index_t perturb;
#endif
st_index_t bin;

ind = hash_bin(hash_value, tab);
#ifdef QUADRATIC_PROBE
d = 1;
#else
peterb = hash_value;
perturb = hash_value;
#endif
FOUND_BIN;
for (;;) {
Expand All @@ -935,7 +935,7 @@ find_table_bin_ind_direct(st_table *tab, st_hash_t hash_value, st_data_t key)
ind = hash_bin(ind + d, tab);
d++;
#else
ind = secondary_hash(ind, tab, &peterb);
ind = secondary_hash(ind, tab, &perturb);
#endif
COLLISION;
}
Expand All @@ -960,7 +960,7 @@ find_table_bin_ptr_and_reserve(st_table *tab, st_hash_t *hash_value,
#ifdef QUADRATIC_PROBE
st_index_t d;
#else
st_index_t peterb;
st_index_t perturb;
#endif
st_index_t entry_index;
st_index_t first_deleted_bin_ind;
Expand All @@ -970,7 +970,7 @@ find_table_bin_ptr_and_reserve(st_table *tab, st_hash_t *hash_value,
#ifdef QUADRATIC_PROBE
d = 1;
#else
peterb = curr_hash_value;
perturb = curr_hash_value;
#endif
FOUND_BIN;
first_deleted_bin_ind = UNDEFINED_BIN_IND;
Expand Down Expand Up @@ -1000,7 +1000,7 @@ find_table_bin_ptr_and_reserve(st_table *tab, st_hash_t *hash_value,
ind = hash_bin(ind + d, tab);
d++;
#else
ind = secondary_hash(ind, tab, &peterb);
ind = secondary_hash(ind, tab, &perturb);
#endif
COLLISION;
}
Expand Down Expand Up @@ -2120,7 +2120,7 @@ st_rehash_indexed(st_table *tab)
#ifdef QUADRATIC_PROBE
st_index_t d = 1;
#else
st_index_t peterb = p->hash;
st_index_t perturb = p->hash;
#endif

if (DELETED_ENTRY_P(p))
Expand Down Expand Up @@ -2153,7 +2153,7 @@ st_rehash_indexed(st_table *tab)
ind = hash_bin(ind + d, tab);
d++;
#else
ind = secondary_hash(ind, tab, &peterb);
ind = secondary_hash(ind, tab, &perturb);
#endif
}
}
Expand Down

0 comments on commit b9f90ca

Please sign in to comment.