summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-14 06:58:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-14 06:58:14 -0800
commit8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0 (patch)
treeacb64699c567dba023fe5c3591fe96e22f3ef2ba /hash.c
parent4477112731119ebc28d5e4a9dce858d8d008af36 (diff)
downloadtxr-8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0.tar.gz
txr-8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0.tar.bz2
txr-8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0.zip
gethash_f: removing function.
Uses of gethash_f can be replaced with gethash_e, which returns the hash cell directly rather than through a loc argument. Code that needs the value can call cdr itself. * hash.c (inhash, hash_isec, hash_update_1): Replace gethash_f with gethash_e. (gethash_f): Function removed. * hash.h (gethash_f): Declaration removed. * lib.c (use_sym, unuse_sym, find_symbol, unintern, intern_fallback, in, sel, populate_obj_hash): Replace gethash_f with gethash_e.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/hash.c b/hash.c
index 6babca4a..64dcf680 100644
--- a/hash.c
+++ b/hash.c
@@ -808,24 +808,16 @@ val gethash(val hash, val key)
val inhash(val hash, val key, val init)
{
val self = lit("inhash");
- val cell;
if (missingp(init)) {
- gethash_f(self, hash, key, mkcloc(cell));
+ return gethash_e(self, hash, key);
} else {
val new_p;
- cell = gethash_c(self, hash, key, mkcloc(new_p));
+ val cell = gethash_c(self, hash, key, mkcloc(new_p));
if (new_p)
rplacd(cell, init);
+ return cell;
}
-
- return cell;
-}
-
-val gethash_f(val self, val hash, val key, loc found)
-{
- set(found, gethash_e(self, hash, key));
- return cdr(deref(found));
}
val gethash_n(val hash, val key, val notfound_val)
@@ -1484,13 +1476,12 @@ val hash_isec(val hash1, val hash2, val join_func)
entry;
entry = hash_next(hiter))
{
- val found;
- val data2 = gethash_f(self, hash2, car(entry), mkcloc(found));
+ val found = gethash_e(self, hash2, car(entry));
if (found) {
if (missingp(join_func))
sethash(hout, car(entry), cdr(entry));
else
- sethash(hout, car(entry), funcall2(join_func, cdr(entry), data2));
+ sethash(hout, car(entry), funcall2(join_func, cdr(entry), cdr(found)));
}
}
@@ -1535,8 +1526,8 @@ val hash_update_1(val hash, val key, val fun, val init)
val self = lit("hash-update-1");
if (missingp(init)) {
- val cons;
- val data = gethash_f(self, hash, key, mkcloc(cons));
+ val cons = gethash_e(self, hash, key);
+ val data = cdr(cons);
if (cons)
rplacd(cons, funcall1(fun, data));
return data;