From 8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Feb 2019 06:58:14 -0800 Subject: 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. --- hash.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'hash.c') 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; -- cgit v1.2.3