diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-01-01 19:56:11 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-01-01 19:56:11 -0800 |
commit | 6ac45e04ea817dcd6df3a749f523ed1b96ec0118 (patch) | |
tree | bfd8211f0d14cbc1978b231b3a2504209f72aa24 /combi.c | |
parent | 79a90b980192de7410a7e688e1c831f7878f8714 (diff) | |
download | txr-6ac45e04ea817dcd6df3a749f523ed1b96ec0118.tar.gz txr-6ac45e04ea817dcd6df3a749f523ed1b96ec0118.tar.bz2 txr-6ac45e04ea817dcd6df3a749f523ed1b96ec0118.zip |
Use rplaca and rplacd instead of set over car_l/cdr_l.
This reduces the proliferation of car_l and cdr_l.
With this change, nreverse should work on chains of
objects that implement rplacd.
* combi.c (comb_gen_fun_common, rcomb_gen_fun_common): Use
rplaca.
* eval.c (mappendv, mapdov): Likewise
* hash.c (hash_equal_op): Likewise.
* lib.c (nreverse, acons_new, aconsql_new, sort_list): Use
rplaca and rplacd.
* match.c (dest_set, v_gather, v_collect, v_flatten, v_cat,
v_output, v_filter): Likewise
* parser.c (ensure_parser): Use sys_rplacd.
* unwind.c (uw_register_subtype): Use rplacd.
Diffstat (limited to 'combi.c')
-rw-r--r-- | combi.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -359,7 +359,7 @@ static void comb_gen_fun_common(val state) val curr = first(iter); val curr_rest = rest(curr); if (curr_rest != prev && consp(curr_rest)) { - set(car_l(iter), curr_rest); + rplaca(iter, curr_rest); return; } else if (rest(iter)) { val next = second(iter); @@ -367,11 +367,11 @@ static void comb_gen_fun_common(val state) val next_rest_rest = rest(next_rest); prev = curr; if (next_rest != curr && consp(next_rest_rest)) - prev = set(car_l(iter), next_rest_rest); + prev = sys_rplaca(iter, next_rest_rest); } } - deref(car_l(state)) = nil; + rplaca(state, nil); } static val comb_list_gen_fun(val state) @@ -520,16 +520,16 @@ static void rcomb_gen_fun_common(val state) if (consp(curr_rest)) { val jter; for (jter = state; jter != next; jter = cdr(jter)) - set(car_l(jter), curr_rest); + rplaca(jter, curr_rest); return; } else if (next) { val next = second(iter); if (curr != next) - set(car_l(iter), rest(next)); + rplaca(iter, rest(next)); } } - deref(car_l(state)) = nil; + rplaca(state, nil); } static val rcomb_list_gen_fun(val state) |