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 /lib.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 'lib.c')
-rw-r--r-- | lib.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -10909,8 +10909,7 @@ static void obj_init(void) /* nil can't be interned because it's not a SYM object; it works as a symbol because the nil case is handled by symbol-manipulating function. */ - rplacd(gethash_c(self, user_package->pk.symhash, - nil_string, nulloc), nil); + sethash(user_package->pk.symhash, nil_string, nil); /* t can't be interned, because intern needs t in order to do its job. */ t = cdr(rplacd(gethash_c(self, user_package->pk.symhash, @@ -11234,19 +11233,19 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) val ret = obj; if (ctx && circle_print_eligible(obj)) { - val cell = gethash_c(self, ctx->obj_hash, obj, nulloc); - val label = cdr(cell); + loc pcdr = gethash_l(self, ctx->obj_hash, obj, nulloc); + val label = deref(pcdr); if (label == t) { val counter = succ(ctx->counter); ctx->counter = counter; - rplacd(cell, counter); + set(pcdr, counter); format(out, lit("#~s="), counter, nao); } else if (integerp(label)) { format(out, lit("#~s#"), label, nao); return ret; } else if (!label) { - rplacd(cell, colon_k); + set(pcdr, colon_k); } } @@ -11681,9 +11680,9 @@ static void obj_hash_merge(val parent_hash, val child_hash) for (iter = hash_begin(child_hash); (cell = hash_next(iter));) { val new_p; - val pcell = gethash_c(self, parent_hash, car(cell), mkcloc(new_p)); + loc pcdr = gethash_l(self, parent_hash, car(cell), mkcloc(new_p)); if (new_p) - rplacd(pcell, cdr(cell)); + set(pcdr, cdr(cell)); else uw_throwf(error_s, lit("~a: unexpected duplicate object " "(internal error?)"), self, nao); |