summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-14 07:22:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-14 07:22:16 -0800
commitee7866ae60fe4357bbcd453dbfdf5a90528dda7b (patch)
treeaa53042bc2d2076fd8d32d3c80400cd977a483c1 /eval.c
parent8c25a6210a1fc44901fd6ebf7fb3f63c0ca5eec0 (diff)
downloadtxr-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 'eval.c')
-rw-r--r--eval.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/eval.c b/eval.c
index 7b8c6b35..6c29a958 100644
--- a/eval.c
+++ b/eval.c
@@ -175,11 +175,11 @@ val env_fbind(val env, val sym, val fun)
cell = acons_new_c(sym, nulloc, mkloc(env->e.fbindings, env));
return rplacd(cell, fun);
} else {
- val hcell = gethash_c(self, top_fb, sym, nulloc);
- val cell = cdr(hcell);
+ loc pcdr = gethash_l(self, top_fb, sym, nulloc);
+ val cell = deref(pcdr);
if (cell)
return rplacd(cell, fun);
- return sys_rplacd(hcell, cons(sym, fun));
+ return set(pcdr, cons(sym, fun));
}
}
@@ -193,11 +193,11 @@ val env_vbind(val env, val sym, val obj)
cell = acons_new_c(sym, nulloc, mkloc(env->e.vbindings, env));
return rplacd(cell, obj);
} else {
- val hcell = gethash_c(self, top_vb, sym, nulloc);
- val cell = cdr(hcell);
+ loc pcdr = gethash_l(self, top_vb, sym, nulloc);
+ val cell = deref(pcdr);
if (cell)
return rplacd(cell, obj);
- return sys_rplacd(hcell, cons(sym, obj));
+ return set(pcdr, cons(sym, obj));
}
}
@@ -5823,13 +5823,13 @@ void reg_var(val sym, val val)
static void reg_symacro(val sym, val form)
{
- val cell = gethash_c(lit("internal initialization"), top_smb, sym, nulloc);
- val binding = cdr(cell);
+ loc pcdr = gethash_l(lit("internal initialization"), top_smb, sym, nulloc);
+ val binding = deref(pcdr);
if (binding)
rplacd(binding, form);
else
- rplacd(cell, cons(sym, form));
+ set(pcdr, cons(sym, form));
}
static val if_fun(val cond, val then, val alt)