diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:22:16 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:22:16 -0800 |
commit | ee7866ae60fe4357bbcd453dbfdf5a90528dda7b (patch) | |
tree | aa53042bc2d2076fd8d32d3c80400cd977a483c1 /hash.c | |
parent | 8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0 (diff) | |
download | txr-ee7866ae60fe4357bbcd453dbfdf5a90528dda7b.tar.gz txr-ee7866ae60fe4357bbcd453dbfdf5a90528dda7b.tar.bz2 txr-ee7866ae60fe4357bbcd453dbfdf5a90528dda7b.zip |
gethash_c: review uses and improve or replace.
* eval.c (env_fbind, env_vbind, reg_symacro): Use gethash_l
instead of gethash_c to eliminate repeated cdr operations
on the same cell.
* hash.c (sethash): Since new_p is never used, eliminated it
and use nulloc.
(group_reduce): Use gethash_l instead of gethash_c.
* lib.c (obj_init): Replace rplacd(gethash_c(...)) pattern
whose return value is not used with with sethash. We lose some
diagnosability here since sethash doesn't take a "self"
argument.
(obj_print_impl, obj_hash_merge): Use gethash_l instead of
gethash_c.
* parser.y (ensure_parser, parser_circ_def, get_visible_syms,
rlset): Use gethash_l instead of gethash_c.
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -830,8 +830,7 @@ val gethash_n(val hash, val key, val notfound_val) val sethash(val hash, val key, val value) { val self = lit("sethash"); - val new_p; - rplacd(gethash_c(self, hash, key, mkcloc(new_p)), value); + rplacd(gethash_c(self, hash, key, nulloc), value); return value; } @@ -1258,24 +1257,24 @@ val group_reduce(val hash, val by_fun, val reduce_fun, val seq, val v = vecref(seq, num_fast(i)); val key = funcall1(by_fun, v); val new_p; - val cell = gethash_c(self, hash, key, mkcloc(new_p)); + loc pcdr = gethash_l(self, hash, key, mkcloc(new_p)); if (new_p) - rplacd(cell, funcall2(reduce_fun, initval, v)); + set(pcdr, funcall2(reduce_fun, initval, v)); else - rplacd(cell, funcall2(reduce_fun, cdr(cell), v)); + set(pcdr, funcall2(reduce_fun, deref(pcdr), v)); } } else { for (; seq; seq = cdr(seq)) { val v = car(seq); val key = funcall1(by_fun, v); val new_p; - val cell = gethash_c(self, hash, key, mkcloc(new_p)); + loc pcdr = gethash_l(self, hash, key, mkcloc(new_p)); if (new_p) - rplacd(cell, funcall2(reduce_fun, initval, v)); + set(pcdr, funcall2(reduce_fun, initval, v)); else - rplacd(cell, funcall2(reduce_fun, cdr(cell), v)); + set(pcdr, funcall2(reduce_fun, deref(pcdr), v)); } } |