summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-06-22 22:22:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-06-22 22:22:04 -0700
commit18a2c93e92482f2408f120c1277a5ba120854f7e (patch)
treec5821d858af7ed516ac0a6968970e09fca4d7511
parentca6b26810adb42e35c32d3f961982fec638d0d4c (diff)
downloadtxr-18a2c93e92482f2408f120c1277a5ba120854f7e.tar.gz
txr-18a2c93e92482f2408f120c1277a5ba120854f7e.tar.bz2
txr-18a2c93e92482f2408f120c1277a5ba120854f7e.zip
hash: rename some variables in remove algorithms
hash.c (hash_remove): In the algorithm that moves cells forward in the cluster in order to avoid the use of tombstones, we use slightly better variables. The cell we are looking to replace is called wipe rather than start. The cryptic varaible name k is renamed to iprobe, because it the initial probe location for the cell at position i.
-rw-r--r--hash.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/hash.c b/hash.c
index dddca0d7..432e8468 100644
--- a/hash.c
+++ b/hash.c
@@ -582,7 +582,7 @@ static val hash_remove(struct hash *h, ucnum victim)
{
val table = h->table;
val *vec = table->v.vec;
- ucnum start = victim, i = start, mask = h->mask;
+ ucnum wipe = victim, i = wipe, mask = h->mask;
val cell = vec[i];
val ret = nil;
val vicentry = vec[victim];
@@ -594,24 +594,24 @@ static val hash_remove(struct hash *h, ucnum victim)
i = (i + 1) & mask;
- while (i != start) {
+ while (i != wipe) {
cell = vec[i];
if (cell == nil) {
break;
} else {
ucnum hcode = cell->ch.hash;
- ucnum k = hcode & mask;
+ ucnum iprobe = hcode & mask;
- if ((i < start) ^ (k <= start) ^ (k > i)) {
- vec[start] = vec[i];
- start = i;
+ if ((i < wipe) ^ (iprobe <= wipe) ^ (iprobe > i)) {
+ vec[wipe] = vec[i];
+ wipe = i;
}
i = (i + 1) & h->mask;
}
}
- vec[start] = nil;
+ vec[wipe] = nil;
bug_unless (h->count > 0);
h->count--;